Usually i'm telling people NOT to put their SQL into the code, pretty
much the same as with templates.
As that needs code to get the SQL from the outside it isn't always
what you want. And with SQL there's more than just ``put different
languages into different files'', it's also about formating.
To achieve that i was using heredocs for a while with different
delimiters until i realized that a semicolon is the best option i
can think of:
$sql = <<';';
SELECT
*
FROM foo
WHERE
id = $1
;
I use q{} (Score:2)
I've never been a big fan of heredocs - mainly because they break indentation. When I put SQL in code, I tend to use the single quote operator with curly braces for delimiters:
Re: (Score:1)