Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Commit

Permalink
Doctrine: use native Paginator from ORM 2.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrtak-CZ committed Apr 26, 2012
1 parent 1e8f88b commit 8165d25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
13 changes: 7 additions & 6 deletions Nella/Doctrine/QueryObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Nella\Doctrine;

use DoctrineExtensions\Paginate\Paginate,
use Doctrine\ORM\Tools\Pagination\Paginator,
Nella\Model\IQueryable;

/**
Expand Down Expand Up @@ -55,7 +55,8 @@ protected function doCreateQuery(IQueryable $broker)
*/
public function count(IQueryable $broker)
{
return Paginate::getTotalQueryResults($this->doCreateQuery($broker));
$tmp = new Paginator($this->doCreateQuery($broker));
return count($tmp);
}

/**
Expand All @@ -66,11 +67,11 @@ public function fetch(IQueryable $broker)
{
$query = $this->doCreateQuery($broker);

if ($this->paginator) { // Paginate
$query = Paginate::getPaginateQuery($query, $this->paginator->getOffset(), $this->paginator->getLength());
}

try{
if ($this->paginator) {
$query->setFirstResult($this->paginator->getOffset())->setMaxResults($this->paginator->getLength());
return new Paginator($query);
}
return $query->getResult();
} catch (\Doctrine\ORM\NoResultException $e) {
return array();
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ Nella Framework requires PHP 5.3.2 with PDO.
- Doctrine ORM 2.2.x
- Symfony Console 2.0.x

Optional

- Doctrine Extension - Paginate


Installation
------------
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"doctrine/orm": ">=2.2.0,<2.2.x-dev",
"doctrine/migrations": "*",
"symfony/console": ">=2.0.0,<2.0.x-dev",
"beberlei/DoctrineExtensions": "*",
"nette/nette": "2.0.*"
},
"replace": {
Expand Down

0 comments on commit 8165d25

Please sign in to comment.