[nycphp-talk] best practice for calling multiple queries?
Kenneth Downs
ken at secdat.com
Wed Apr 2 14:58:49 EDT 2008
Daniel Convissor wrote:
> Hi Kristina:
>
> On Wed, Apr 02, 2008 at 08:49:08AM -0700, Kristina Anderson wrote:
>
>> I name each query $query1,
>> query2, etc rather than what I see in a lot of PHP code I've inherited,
>> where each query is simply named $query, even if there are 6 or 7 of
>> them on the page.
>>
>
> I use $sql for all queries. It's short and to the point. Plus it
> ensures you're running the most recenlty defined $sql and are not adding
> overhead with extra variables. It also allows you to copy and paste the
> actual query execution line over and over and over without having to
> worry (which is probably how your bug got introduced).
>
> Even if you want to give each query string a unique variable name, don't
> name them 1, 2, 3. Give them real names that descirbe what they are.
>
Normally I wouldn't waste bandwidth with a "me too" response, but Dan's
reply here is very clear and to the point. Simplicity can be a very
powerful productivity tool.
--
Kenneth Downs
Secure Data Software, Inc.
www.secdat.com www.andromeda-project.org
631-689-7200 Fax: 631-689-0527
cell: 631-379-0010
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080402/65a9df91/attachment.html>
More information about the talk
mailing list