public function __construct(QueryBuilder $query, $fetchJoinCollection = true) { $countQuery = clone $query; $countQuery = $countQuery->select('count(e) as c')->setFirstResult(0)->setMaxResults(1)->getQuery(); $this->countQuery = $countQuery; parent::__construct($query, $fetchJoinCollection); }
public function __construct(QueryBuilder $qb, $limit, $page = 1) { $offset = ($page - 1) * $limit; $qb->setFirstResult($offset)->setMaxResults($limit); $this->page = $page; $this->limit = $limit; parent::__construct($qb); }
/** * __construct * * @param Dql $dql * @param integer $page * @param integer $limit */ public function __construct($dql, $page = 1, $limit = 15) { parent::__construct($dql); $this->setPageAndLimit($page, $limit); //Set limit $this->getQuery()->setFirstResult($this->limit * ($this->page - 1))->setMaxResults($this->limit); //Calculate $this->totalRecordReturned = $this->getIterator()->count(); $this->totalRecord = $this->count(); $this->maxPage = ceil($this->totalRecord / $this->limit); }
public function __construct(\Doctrine\ORM\AbstractQuery $query, $currentPage, $pageSize, $showNumbers = 5, $fetchJoinCollection = true) { parent::__construct($query, $fetchJoinCollection); $query->setFirstResult($pageSize * ($currentPage - 1))->setMaxResults($pageSize); // set the limit; $this->pageSize = $pageSize; $this->totalItems = count($this); $this->totalPage = ceil($this->totalItems / $query->getMaxResults()); $this->currentPage = max(1, min($this->totalPage, $currentPage)); $this->firstPage = 1 + intval(($this->currentPage - 1) / $showNumbers) * $showNumbers; $this->lastPage = min($this->firstPage + $showNumbers - 1, $this->totalPage); }
/** * Constructor. * * @param Query|QueryBuilder $query * A Doctrine ORM query or query builder. * @param boolean $fetchJoinCollection * Whether the query joins a collection (true by default). * @param boolean $cache * Use result cache (true by default). * @param boolean $count * Execute count query (true by default). */ public function __construct($query, $fetchJoinCollection = true, $cached = true, $count = true) { if ($count) { $countQuery = clone $query; $countQuery = $countQuery->select('count(e) as c')->setFirstResult(0)->setMaxResults(1)->getQuery(); $this->countQuery = $countQuery; } $q = $query; if ($cached) { $this->cache_prefix = ''; if ($query instanceof QueryBuilder) { $q = $query->getQuery(); $entities = $query->getRootEntities(); if ($entities) { $entity = $entities[0]; $this->cache_prefix = strtolower(substr(strrchr($entity, '\\'), 1) ?: $entity) . '-'; } } $q->useQueryCache(true)->useResultCache(true, 3600, $this->cache_prefix . md5($q->getDQL())); } parent::__construct($q, $fetchJoinCollection); }
public function __construct($query, $fetchJoinCollection = false) { return parent::__construct($query, $fetchJoinCollection); }
public function __construct($query, $queryIds = null, $fetchJoinCollection = true) { parent::__construct($query, $fetchJoinCollection); $this->queryIds = $queryIds; }
/** * Constructor. * * @param Query|QueryBuilder $query A Doctrine ORM query or query builder. * @param Boolean $fetchJoinCollection Whether the query joins a collection (true by default). */ public function __construct($query, $fetchJoinCollection = true) { parent::__construct($query, $fetchJoinCollection); // We have to use the SQL Server query walker to get the correct wrapping. $this->getQuery()->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'DoctrineSqlServerExtensions\\ORM\\Query\\AST\\SQLServerSqlWalker'); }
/** * @param QueryBuilder $builder * @param Search $search */ public function __construct(QueryBuilder $builder, Search $search) { $this->builder = $builder; $this->search = $search; parent::__construct($builder); }
public function __construct(Query $query, $currentPage = 1) { parent::__construct($query); $this->currentPage = (int) $currentPage; }