src/Colorium/Orm/SQL.php
public static function select($table, array $fields, array $where = [], array $sort = [], array $limit = [])
    {
        $sql = $values = [];
        $sql[] = 'SELECT ' . implode(', ', $fields);
        $sql[] = 'FROM ' . static::e($table);

        if($where) {
            $items = [];
            foreach($where as $exp => $data) {
                $items[] = $exp;
                if(is_array($data)) {
                    $values = array_merge($values, $data);
                    continue;
                }
                $values[] = $data;
            }
            $sql[] = 'WHERE ' . implode(' AND ', $items);
        }

        if($sort) {
            $items = [];
            foreach($sort as $field => $direction) {
                $items[] = static::e($field) . ' ' . ($direction == SORT_DESC ? 'DESC' : 'ASC');
            }
            $sql[] = 'ORDER BY ' .implode(', ', $items);
        }

        if($limit) {
            $sql[] = 'LIMIT ' . $limit[0] . ', ' . $limit[1];
        }

        $sql = implode("\n", $sql);
        return [$sql, $values];
    }
public static function select($table, array $fields, array $where = [], array $sort = [], array $limit = [])
    {
        $sql = $values = [];
        $sql[] = 'SELECT ' . implode(', ', $fields);
        $sql[] = 'FROM ' . static::e($table);

        if($where) {
            $items = [];
            foreach($where as $exp => $data) {
                $items[] = $exp;
                if(is_array($data)) {
                    $values = array_merge($values, $data);
                    continue;
                }
                $values[] = $data;
            }
            $sql[] = 'WHERE ' . implode(' AND ', $items);
        }

        if($sort) {
            $items = [];
            foreach($sort as $field => $direction) {
                $items[] = static::e($field) . ' ' . ($direction == SORT_DESC ? 'DESC' : 'ASC');
            }
            $sql[] = 'ORDER BY ' .implode(', ', $items);
        }

        if($limit) {
            $sql[] = 'LIMIT ' . $limit[0] . ', ' . $limit[1];
        }

        $sql = implode("\n", $sql);
        return [$sql, $values];
    }
Compile SELECT

@param string $table
@param array $fields
@param array $where
@param array $sort
@param array $limit
@return array