RE: [PHP] Re: Vars inside an sql query [Regular expression question]
| From: | Jay Blanchard | Date: | Thu, 12 Jun 2003 13:17:00 +0000 |
| Subject: | RE: [PHP] Re: Vars inside an sql query [Regular expression question] | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-151244@lists.php.net to get a copy of this message | ||
[snip]
$string = "select * FROM
table where id='$value' order by name";
[/snip]
I know it ain't pretty, but the coding style we have accepted is
this....
$string = "select * FROM table where id = '" . $value . "'
order by
name ";
or (we requite caps on reserved words)...
$string = "SELECT * ";
$string .= "FROM table ";
$string .= "WHERE id = '" . $value . "' ";
$string .= "ORDER BY name ";
No ambiguity and cleaner on longer queries.
It's all in preference I suppose.
Jay