// composer.json
{
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"beberlei/doctrineextensions": "^1.3", // v1.3.0
"doctrine/doctrine-bundle": "^2.7", // 2.9.1
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.2.2
"doctrine/orm": "^2.13", // 2.15.1
"symfony/asset": "6.2.*", // v6.2.7
"symfony/console": "6.2.*", // v6.2.10
"symfony/dotenv": "6.2.*", // v6.2.8
"symfony/flex": "^2", // v2.2.5
"symfony/framework-bundle": "6.2.*", // v6.2.10
"symfony/proxy-manager-bridge": "6.2.*", // v6.2.7
"symfony/runtime": "6.2.*", // v6.2.8
"symfony/twig-bundle": "6.2.*", // v6.2.7
"symfony/webpack-encore-bundle": "^1.16", // v1.16.1
"symfony/yaml": "6.2.*" // v6.2.10
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4", // 3.4.4
"symfony/maker-bundle": "^1.47", // v1.48.0
"symfony/stopwatch": "6.2.*", // v6.2.7
"symfony/web-profiler-bundle": "6.2.*", // v6.2.10
"zenstruck/foundry": "^1.22" // v1.32.0
}
}
Ya sabes hacer consultas con SQL, ¡así que aprender a hacer consultas complejas con Doctrine no debería ser un suplicio! En este tutorial, aprenderemos sobre:
QueryBuilder
Criteria
para filtrar eficazmente colecciones de relaciones¡Y mucho más! ¡Veamos qué tipo de consultas locas podemos crear!
Hey Lionel,
Unfortunately, no. But it should be the same DQL query in another DQL, this should work. But subqueries are mostly bad idea, sometimes it might be better (much better performance) to execute 2 separate queries. If you use subqueries - I would recommend you to profile those queries to see how long they are executing, then rewrite logic with 2 queries and compare. I bet in most cases 2 separate queries will be faster.
Cheers!
Great news! I would like to take this opportunity to share this article with you: https://soyuka.me/esql-alternative-to-doctrine-query-language-why/
Maybe it could give you some ideas 😇
The article is quite interesting. But try https://api-platform.com/docs/core/serialization/#embedding-relations . Probably you will achieve the same. If not, you would probably have to look at Doctrine and the Eager Loading. But I have to admit that in my first project with API Platform I encountered an unfavorable combination, combined with quite interesting bugs that e.g. made a difference on which platform the project was built... So I am not completly sure...
Thank you for your answer, do you have an example, or a link that shows the use of Eager Loading?
In combination with API-Platform it is explained here: https://api-platform.com/docs/core/performance/#eager-loading. There are multiple ways.
But I don't see an example for fetching an embedded relation one time with, and another without an eager collection, depending on the route.
For example you have customers with invoices, and each invoice has many products on it.
If you want to show an overview of the invoices you want to show all invoices and a number of positions, but not the product Detail-Data.
But if you want to show an invoice you want to show the invoices with the product data.
I think in this case, you can create a second getter, giving the exact same relation with another name and wihtout eager loading. In combination with https://api-platform.com/docs/core/serialization/#embedding-relations > Normalization Groups ( #[Groups('book')] ) even this should be possbile.
Hi guys will you talk about adding a subquery?