Skip to content

Commit

Permalink
Added documentation about the feature
Browse files Browse the repository at this point in the history
Doc update
  • Loading branch information
Nek- committed Jan 2, 2015
1 parent b14c64d commit 3b2e6de
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,34 @@ To paginate [DoctrineORM](http://www.doctrine-project.org/projects/orm) query ob
```php
<?php

use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Adapter\DoctrineORMAdapter;

$queryBuilder = $entityManager->createQueryBuilder()
->select('u')
->from('Model\Article', 'u');
$adapter = new DoctrineORMAdapter($queryBuilder);
```

### DoctrineORMNativeQueryAdapter

To paginate [Doctrine native queries](http://doctrine-orm.readthedocs.org/en/latest/reference/native-sql.html) objects.

```php
<?php

use Pagerfanta\Adapter\DoctrineORMNativeQueryAdapter;
use Doctrine\ORM\Query\ResultSetMappingBuilder;

$query = 'SELECT * FROM article';

$rsm = new ResultSetMappingBuilder($entityManager);
$rsm->addRootEntityFromClassMetadata('Pagerfanta\Tests\Adapter\DoctrineORM\User', 'u');

$adapter = new DoctrineORMNativeQueryAdapter($nq);
```

> The adapter accept 2 callable that should modify a given (as parameter) native query to respectively: make a count query / make a slice query
### DoctrineODMMongoDBAdapter

To paginate [DoctrineODMMongoDB](http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/) query builders.
Expand Down
1 change: 1 addition & 0 deletions src/Pagerfanta/Adapter/DoctrineORMNativeQueryAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class DoctrineORMNativeQueryAdapter implements AdapterInterface
/**
* @param NativeQuery $query A DBAL query builder.
* @param callable $countQueryBuilderModifier A callable to modify the query to count.
* @param callable $sliceQueryBuilderModifier A callable to modify the query to slice it (the default should do the job most part of the time).
* @throws InvalidArgumentException
*/
public function __construct(NativeQuery $query, $countQueryBuilderModifier = null, $sliceQueryBuilderModifier = null)
Expand Down

0 comments on commit 3b2e6de

Please sign in to comment.