Can someone provide me with a couple of clear (confirmed facts) reasons to use / learn DQL or SQL when you need a custom query when working with Doctrine classes?
I find that if I cannot use ORM's built-in relational functionality to accomplish something, I usually write my own method in the extended Doctrine or DoctrineTable class. In this method, write what you need in direct SQL (using PDO with appropriate prepared instructions / injection protection, etc.). DQL seems to be an additional language for training / debugging / support, which does not appear, which provides sufficient convincing reasons for use in most common situations. DQL does not seem to be much more complicated than SQL to guarantee its use - in fact, I doubt that you could use DQL effectively without having a solid understanding of SQL. Most of the basic SQL syntax ports are pretty good for most of the common databases you will use with PHP.
What am I missing / not? I am sure there is a reason, but I would like to hear from people who intentionally used it significantly and what was achieved when trying to work with a simple SQL language.
I'm not looking for an argument that supports ORM, just DQL, when you need to do something outside of the basic needs of a get-by-relationship type, in a traditional LAMP setup (using mysql, postgres, etc.).
source share