Re: Style questions: variable in echo, preparing sql queries
| From: | Ignacio Vazquez-Abrams | Date: | Wed, 22 Nov 2000 21:18:07 +0000 |
| Subject: | Re: Style questions: variable in echo, preparing sql queries | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26712@lists.php.net to get a copy of this message | ||
On Wed, 22 Nov 2000, Chris Lott wrote:
> Two questions about style:
>
> 1) echo "PartID is $PartID";
> seems to work fine. Is there a reason that I see others use:
> echo "PartID is " . $PartID;
Personal preference.
> 2) When querying a db, I see users who do something like:
> $sql = "select foo from bar";
> $results = mysql_query("$sql")
> Is there a reason not to just put the SQL code directly in the function:
> $results=mysql_query("select foo from bar") ?
What if the query changes? What if the query is no longer a static
string? It's all about flexibility. And personal preference, of
course.
> c
>
--
Ignacio Vazquez-Abrams <ignacio@openservices.net>