// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"babdev/pagerfanta-bundle": "^3.7", // v3.7.0
"doctrine/doctrine-bundle": "^2.7", // 2.7.0
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.2.2
"doctrine/orm": "^2.12", // 2.12.3
"knplabs/knp-time-bundle": "^1.18", // v1.19.0
"pagerfanta/doctrine-orm-adapter": "^3.6", // v3.6.1
"pagerfanta/twig": "^3.6", // v3.6.1
"sensio/framework-extra-bundle": "^6.2", // v6.2.6
"stof/doctrine-extensions-bundle": "^1.7", // v1.7.0
"symfony/asset": "6.1.*", // v6.1.0
"symfony/console": "6.1.*", // v6.1.2
"symfony/dotenv": "6.1.*", // v6.1.0
"symfony/flex": "^2", // v2.4.5
"symfony/framework-bundle": "6.1.*", // v6.1.2
"symfony/http-client": "6.1.*", // v6.1.2
"symfony/monolog-bundle": "^3.0", // v3.8.0
"symfony/proxy-manager-bridge": "6.1.*", // v6.1.0
"symfony/runtime": "6.4.3", // v6.4.3
"symfony/twig-bundle": "6.1.*", // v6.1.1
"symfony/ux-turbo": "^2.0", // v2.3.0
"symfony/webpack-encore-bundle": "^1.13", // v1.15.1
"symfony/yaml": "6.1.*", // v6.1.2
"twig/extra-bundle": "^2.12|^3.0", // v3.4.0
"twig/twig": "^2.12|^3.0" // v3.4.1
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4", // 3.4.2
"symfony/debug-bundle": "6.1.*", // v6.1.0
"symfony/maker-bundle": "^1.41", // v1.44.0
"symfony/stopwatch": "6.1.*", // v6.1.0
"symfony/web-profiler-bundle": "6.1.*", // v6.1.2
"zenstruck/foundry": "^1.21" // v1.21.0
}
}
12 Comments
Hey SymfonyCast!
I had a question about querying images from the database. Would it be better to make URL requests for images statically from api's or is it better to query images from the database? And yes, I've learned that Doctrine queries the database in the background; with the focus on instantiating objects not tables.
Hey @Akili
It's better only to store info about the image in the database, for example their filename, render an
imgtag pointing to the file, and let the browser request them.Cheers!
There is a typo at 3:50 in the query "vinly_mix"
Wow, nice catch! Thank you for reporting it
I'm wondering how the setParameter method makes the subsequent SQL safer. Does it do something to parse the string to clean it up, or does it use native SQL features to pass the parameters (and hence let the database worry about wrapping the parameter)?
Hi,
Yeah, the doctrine will cover you with parameters so it is safe just pass it to
->setParameter(). I can't describee how exactly it works internally, Doctrinie code is not so cool to exploreCheers
How is it possible to match the aliases with a QueryBuilder provided by a third party?
`
`
For example I'm trying to reuse a QueryBuilder with this design in EasyAdmins createIndexQueryBuilder(). But EasyAdmin uses a generic 'entity' as its alias. Because I am passing parent::createIndexQueryBuilder(...) to my QueryBuilder the aliases do not match up. Is there any solution?
Hey,
You can get an alias from
QueryBuilderobject with->getRootAliases()it will return array of aliases and first element will be your alias!Cheers!
I read about that method but wasn't sure wich key would be safe to use. If first key is always the entity key, then a huge "Thanks" for pointing that out. Appreciate the quick response!
As I know the first key is safe to use as entity key. I didn't heard about another behaviour.
Cheers!
Wouldn't a method like the following be more flexible?
By the way, whats a better coding style for the null coalescing operator .. ?? or you use ?:
Hey Ruflex,
It depends on your use cases. If you need an additional control - passing the column as an argument to the method like you're doing is a good idea. But if you need that flexibility - better make it simple as in our case :) And as always, the simplest your code - the easier to maintain it for other people, or even for you in the future ;)
About "??" or "?:" - that's not about coding style actually because it's a different implementation. Read about both of them in the PHP docs to understand the difference. In short, if the var might not exist - you should use ??, but if it always exists but might just be null sometimes - ?: syntax is enough.
Cheers!
"Houston: no signs of life"
Start the conversation!