Reputation: 1208
When using QueryBuilder object with like
inside having
as below:
$queuebuilder->addSelect('c.customercount*5 as count');
$queuebuilder->add('having', 'count like \'sometext\'');
I get an error:
[Syntax Error] line 0, col 741: Error: Expected '.' or '(', got count
This happpens only with aliased coloumn. How to avoid the error? thank you.
Upvotes: 1
Views: 189
Reputation: 14747
Try something like this:
$qb->select('count(c.customer) as count');
$qb->having('count > x');
If you want to include where statements you could do something like this:
$qb->select('count(c.customer) as count');
$qb->where('c.username = :username');
$qb->having('count > ?1');
$qb->setParameter('username', "foo");
$qb->setParameter(1, 3); //havin count > 3
Upvotes: 0