0

Although the name is SQL Query Builder, it seems to be a way to generate DQL statements, not SQL, as indicated by the note at The QueryBuilder and corroborated by this question: doctrine: QueryBuilder vs createQuery?.

So it seems to me that the names used in the query built with SQL Query Builder don't refer to SQL tables and columns but rather to classes and properties corresponding to them in the defined mapping. And if the mapping changes so that e.g. an SQL column which still has the same name is now reflected by way of ORM by a differently named property, I'd have to accordingly change the code using SQL Query Builder. On the other hand, if the names change in the database and I'm fine with keeping the existing mapped names, I just need to change the annotations on the classes and their properties, and the queries will work without modification. Am I right? If not, how so and what's the right way to understand it?

ByteEater
  • 885
  • 4
  • 13
  • Bing Chat told me otherwise, but it's quite often wrong about such specific things, so I hope somebody with actual intelligence, not artificial, can give me clarity. – ByteEater Apr 17 '23 at 21:13
  • Or am I confusing ORM QueryBuilder and DBAL QueryBuilder, differentiated here: https://stackoverflow.com/questions/36959801/doctrine-orm-querybuilder-or-dbal-querybuilder? – ByteEater Apr 17 '23 at 21:16
  • 1
    Yes you are confusing the two query builders. The ORM DQL builder uses object property names. The DBAL SQL builder will use table column names. In theory you can change the database names, tweak your mapper annotations and keep going as long as you stick to the orm. – Cerad Apr 18 '23 at 01:22

0 Answers0