Answer the question
In order to leave comments, you need to log in
How to create a query in doctrine?
Hello! I'm trying to make a query with a union, but there is not enough knowledge.
public function findAllProductsWithCategory()
{
$entityManager = $this->getEntityManager();
$queryBuilder = $entityManager->createQueryBuilder();
$queryBuilder->select('p')
->from(Products::class, 'p')
->join(Category::class, 'c')
->where('p.category_id = c.id')
->orderBy('p.id', 'DESC');
return $queryBuilder->getQuery();
}
Error producing an iteratorAnd it is not the line in the view where the cycle begins with the object passed there from the request.
public function getIterator()
{
try {
return $this->getCurrentItems();
} catch (\Exception $e) {
throw new Exception\RuntimeException('Error producing an iterator', null, $e);
}
}
"date.timezone" is not set in php.ini.or bad DQL. I believe that I have a problem with the request, because before that all requests worked fine!
Answer the question
In order to leave comments, you need to log in
In the docblock of the join method, an example of usage
$qb = $em->createQueryBuilder()
->select('u')
->from('User', 'u')
->join('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question