Answer the question
In order to leave comments, you need to log in
How to build a query in QueryBuilder in parts?
Where can I see a good example of building a query/s with a QueryBuilder from "pieces"? I don't know how to put it more clearly. The topic was found by me here https://symfonycasts.com/screencast/symfony-doctri... but only on the example of one method:
private function addIsPublishedQueryBuilder(QueryBuilder $qb)
{
return $qb->andWhere('a.publishedAt IS NOT NULL');
}
Answer the question
In order to leave comments, you need to log in
I suspect that the fluent interface was meant by the pieces, something like this then:
$qb->andWhere('a.publishedAt IS NOT NULL')
->andWhere('a.status = :status')
->setParameter('status' , 'gggg');
if ($hhh === $bbb) {
$qb->andWhere('a.hhh = 1')
}
return $qb;
I wrote a builder, this is not a thankful job
About five years ago there was a wrapper around mysqli with fetch and other things
. Then I decided to go only to the builder
https://github.com/Compolomus/SQLQueryBuilder
There is a lot of magic there. But the principle must be clear
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question