Answer the question
In order to leave comments, you need to log in
How to pull multiple values in one query?
The question is probably incorrectly posed, but I don’t understand which side to approach it
in one table there are several values \u200b\u200bwith category IDs,
although the entity has different fields, but the categories are in the same table
, I made such a crutch, but I understand that this is not very
I'm stupid - I don't understand how to optimize the query
$qb
->select('s.id')
->addSelect('s.title')
->addSelect('s.quantity')
->addSelect('s.productCategoryId')
->addSelect('cl.name as productCategoryName')
->addSelect('a.name as accessoryCategoryName')
->addSelect('s.products')
->addSelect('s.attributes')
->addSelect('s.accessoryCategoryId')
->addSelect('s.accessories')
->from(Scenario::class, 's')
->leftJoin(Category::class, 'cl', 'WITH', 's.productCategoryId = cl.id_category')
->leftJoin(Category::class, 'a', 'WITH', 's.accessoryCategoryId = a.id_category')
->where('s.id = :id')
->setParameter('id', $id);
$query = $qb->getQuery();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question