@motofix I fully agree that building queries via string concat is the wrong approach.
But SQL is a robust, powerful, nuanced language, and adding 10,000 lines of code on top of them that ultimately is running 90% "read from one table into a record object, with 1:1 matching" but makes just writing a bloody SQL query 10x harder is also the wrong approach.
And if you're writing your own almost-SQL DDL on top of it to parse and translate, then you've just lost and should give up. (JPA or Doctrine)