Tester
Tester

Reputation: 35

Execute raw SQL using Doctrine 2 with Doctrine paginator

I'm trying to do the pagination, but there is an error:

$dql = "SELECT cast(ip as CHAR) as ip FROM histories";
$query = $em->createQuery($dql)->setFirstResult($offset)->setMaxResults($limit); 
$paginator = new Paginator($query);  
$maxpage = ceil($paginator->count() / $limit);

Error

[Syntax Error] line 0, col 7: Error: Expected IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression, got '*'

$maxpage = ceil($paginator->count() / $limit); //error line

Upvotes: 1

Views: 1062

Answers (1)

Smaïne
Smaïne

Reputation: 1389

Please try that :

$maxpage = ceil(count($paginator) / $limit);

Read the doc

Upvotes: 1

Related Questions