Find by column from the database
@param string $column
@param int $limit
@param string $order
@return mixed
439460
public static function findColumn (string $column, int $limit=0, string $order="DESC")
	{
		$order 		= static::validateOrder($order);
        $dbObject 	= Database::getInstance();
        $column 	= $dbObject->escapeValue($column);
		return static::limitFindBySql("SELECT {$column} FROM ".static::$tableName." ORDER BY id {$order}", $limit);
	}
1267204
public function findLastCreated($limit = 5)
    {
        $query = $this->createQueryBuilder('c')
            ->orderBy('c.createdAt', 'DESC')
            ->setMaxResults($limit)
            ->getQuery();

        return $query->getResult();
    }
585095
public function paginate($limit = null, $columns = ['*'], $method = "paginate")
    {
        return parent::paginate(
            $limit,
            $this->getColumnsNames($columns),
            $method
        );
    }
185777
public function unlimitedRowCount($column = null)
    {
        // we can't clear the select if we're relying on its output by a HAVING clause
        if (count($this->having)) {
            $records = $this->execute();
            return $records->numRecords();
        }

        $clone = clone $this;
        $clone->limit = null;
        $clone->orderby = null;

        // Choose a default column
        if ($column == null) {
            if ($this->groupby) {
                // @todo Test case required here
                $countQuery = new SQLSelect();
                $countQuery->setSelect("count(*)");
                $countQuery->setFrom(array('(' . $clone->sql($innerParameters) . ') all_distinct'));
                $sql = $countQuery->sql($parameters); // $parameters should be empty
                $result = DB::prepared_query($sql, $innerParameters);
                return (int)$result->value();
            } else {
                $clone->setSelect(array("count(*)"));
            }
        } else {
            $clone->setSelect(array("count($column)"));
        }

        $clone->setGroupBy(array());
        return (int)$clone->execute()->value();
    }
630554
public function getQueryResults($limit = null)
    {
        if (isset($limit)) {
            $this->queryBuilder->setMaxResults($limit);
        }
        
        if (!$this->queryBuilder->getDQLPart('orderBy')) {
            $this->queryBuilder->orderBy('a.createdAt', 'ASC');
        }

        return $this->queryBuilder->getQuery()->getResult();
    }
573567
public function getNotifications($limit = null, $order = 'desc')
    {
        $query = $this->getNotificationRelation()->orderBy('created_at', $order);
        if (! is_null($limit)) {
            $query->limit($limit);
        }

        return $query->get();
    }
655672
public function getNotificationsNotRead($limit = null, $order = 'desc')
    {
        $query = $this->getNotificationRelation()->byRead(0)->orderBy('created_at', $order);
        if (! is_null($limit)) {
            $query->limit($limit);
        }

        return $query->get();
    }
31472
public function get(
        $where = null,
        $order = null,
        $limit = null,
        $offset = null,
        $columns = null,
        $group = null,
        $having = null
    ) {
        $result = parent::get($where, $order, $limit, $offset, $columns, $group, $having);
        return $result;
    }
907663
public function search(Search $entity, $limit, $offset, $sort_column, $sort_direction)
    {
        $selector = $this->selector
            ->create()
            ->addCountry($entity)
            ->addDateAdd($entity)
            ->addDateEnd($entity)
            ->addDatePremiere($entity)
            ->addGenres($entity)
            ->addLabels($entity)
            ->addName($entity)
            ->addStorage($entity)
            ->addStudio($entity)
            ->addType($entity)
            ->sort($sort_column, $sort_direction)
            ->limit($limit)
            ->offset($offset);

        return [
            'list' => $selector
                ->getQuerySelect()
                ->getQuery()
                ->getResult(),
            'total' => $selector
                ->getQueryTotal()
                ->getQuery()
                ->getSingleScalarResult(),
        ];
    }
43887
public function column($column = null)
	{
		if($column !== null)
		{
			$this->select([$column]);
		}

		$query = $this->limit(1)->compiler->select();

		return $this->connection->column($query['sql'], $query['params']);
	}
878029
function find(array $where = null, $order = null, $limit = 0, $offset = 0, $lock = null) {
		$query = $this->getQueryWriter()->reset();
		$query->write("SELECT * FROM", $this->conn->quoteName($this->name));
		if ($where) {
			$query->write("WHERE")->criteria($where);
		}
		if ($order) {
			$query->write("ORDER BY", $order);
		}
		if ($limit) {
			$query->write("LIMIT", $limit);
		}
		if ($offset) {
			$query->write("OFFSET", $offset);
		}
		if ($lock) {
			$query->write("FOR", $lock);
		}
		return $this->execute($query);
	}
429392
function of(Row $foreign, $ref = null, $order = null, $limit = 0, $offset = 0) {
		// select * from $this where $this->$foreignColumn = $foreign->$referencedColumn
		
		if (!($rel = $this->getRelation($foreign->getTable()->getName(), $ref))) {
			return $this->onResult(null);
		}
		
		$where = array();
		foreach ($rel as $key => $ref) {
			$where["$key="] = $foreign->$ref;
		}
		
		return $this->find($where, $order, $limit, $offset);
	}
757594
public function select($field = null, $where = null, $order = null, $limit = null)
    {
        //如果未提供条件/排序/分页参数
        if (!$where and !$order and !$limit) {
            //并且未提供字段参数,则表明是之前已经提供,现在要真正执行
            if (!$field) {
                return $this->go();
            }

            //只提供了字段, 并不真正执行, 这里很诡异
            return $this->fields($field);
        }
        //提供了多项,则,设置并执行
        $result = parent::selectArray($field, $where, $order, $limit);
        return new Result($this->tableName, $result);
    }
869039
final protected function order_by($column, $order = 'ASC'){
        $order = 'DESC' === strtoupper($order) ? 'DESC' : 'ASC';
        $this->_order_by[] = sprintf('%s %s', $this->escape_column_name($column), $order);
        return $this;
    }
469963
public function get($table = '', $start = 0, $limit = 0, array $order = array(), array $where = array())
    {
        $parameters = array(
            'start' => $start,
            'limit' => $limit,
            'order' => $order,
            'where' => $where,
        );

        $parameters = array_filter($parameters);

        return $this->makeRequest($this->endpoint.'/'.$table, $parameters);
    }
408590
public function sql(string $fields = null, string $where = null, string $orderBy = null, string $limit = null): string
    {
        $this->statement->select($fields, $where, $orderBy, $limit);

        // 语句真正被创建
        $this->statement->create();

        // 返回相应的SQL语句
        return $this->statement->getSql();
    }
250354
public function findAll( $where     = null,
                             $order     = null,
                             $limit     = null,
                             $offset    = null )
    {
        $iterator = $this->findIterator( $where, $order );

        if ( $limit || $offset )
        {
            $iterator = new LimitIterator(
                $iterator,
                (int) $offset,
                (int) $limit ?: null
            );
        }

        return $iterator;
    }