Re: most powerful php editor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Miles Thompson wrote:
More seriously, many times I've taken a "It's right, but not working, dammit!" SQL statement, broken it up so it's listed "vertically" and discovered the error.
Just my 2 cents worth...

SQL actually does lend itself rather well to normal code style indenting, even though not many seem to do it...Breaking it (and PHP code of course) into 78/80-char lines makes great sense for readability within PHP code:

$sql = "
   SELECT
       (list of fields),
       CASE ... END AS field
       ...
   FROM (table)
   JOIN (table) USING(column)
   JOIN (table) ON(column=column)
   ...
   WHERE
       (condition)
   AND
       (
          (sub-condition)
       OR
          (sub-condition)
       )
   GROUP BY (column)
   ...
";

These things are a real pain to read without formatting! :-)

I think writing unformatted SQL queries is like writing code like "if ($var) { statement; statement; statement; foreach ($var as $v) { statement; statement; statement; } statement; etc. }"

jon

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux