catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

add return type #405

Closed saeedvir closed 3 years ago

saeedvir commented 8 years ago

hi,please add return type for ex. 'json' or ...

SyuTingSong commented 8 years ago

what's ex?

saeedvir commented 8 years ago

//for get function in medoo <?php public function get($table, $join = null, $column = null, $where = null) { $query = $this->query($this->select_context($table, $join, $column, $where) . ' LIMIT 1'); if ($query) { $data = $query->fetchAll(PDO::FETCH_ASSOC); if (isset($data[ 0 ])) { $column = $where == null ? $join : $column; if (is_string($column) && $column != '*') {

                if($this->return_type==='json')
                    return json_encode(array($data[ 0 ][ $column ]));
                else
                    return $data[ 0 ][ $column ];
            }
                if($this->return_type==='json')
                    return json_encode(array($data[ 0 ]));
                else
                    return $data[ 0 ];
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}

?>