Newer
Older
abstract class SelectQueryBuilder extends QueryBuilder implements DoesSelectQuery, DoesSelectQueryByEntryId
/** @inheritdoc */
public function queryByEntryId($entryId)
return $this->is($this->getEntryIdColumn(), $entryId);
}
/**
* @param string $column Column to orderby.
* @param bool $ascending Optional. To use ascending order? If false, descending is used. True is the default.
* @return $this
*/
$this->getCurrentQuery()->orderBy($column, $order);
/**
* Add pagination to a query
*
* @param int $page What page of query
* @param int $limit How many per page
*
* @return $this
*/
public function addPagination( $page, $limit = 25 )
{
$start = 1 + ( $page * $limit) - $limit;
$last = $page * $limit;
$this->getCurrentQuery()->limit((int)$start, (int)$last );
return $this;
}
/**
* @return Select
*/
protected function getCurrentQuery()
{
return $this->getSelectQuery();
}
/** @inheritdoc */
public function resetQuery()
{
$this->setNewQuery();
return $this;
}
private function setNewQuery()
{
$this->selectQuery = new \NilPortugues\Sql\QueryBuilder\Manipulation\Select($this->getTableName());
}