NYCPHP Meetup

NYPHP.org

[nycphp-talk] best practice for calling multiple queries?

Kristina Anderson ka at kacomputerconsulting.com
Wed Apr 2 17:10:11 EDT 2008


if the memory is freed when you reuse the variable names, then probably 
from a performance standpoint that is the best way to do it?

Hmm.


> On Wed, Apr 2, 2008 at 11:49 AM, Kristina Anderson
> <ka at kacomputerconsulting.com> wrote:
> > One thing that I've taken away from this (aside from feeling like an
> >  idiot!) is that one reason for my introduction of these bugs is a
> >  holdover from my "ASP" coding style where 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.
> >
> >  What is the accepted best practice here?  I find it very confusing 
to
> >  try to read code with 16 items each named $query or $result, but
> >  my "ASP" style code is clearly introducing other editing issues.
> 
> I don't see how query1, query2 would be any more clear than just using
> the same variable name.  Using the same variable name indicates that
> the previous statement will not be used again and frees the memory.  I
> prefer using names like $sql and $cursor over $query and $result,
> because they are more accurate names.  It is clear that "sql" is a
> string, and a "cursor" is a pointer to a result set, not actual data.
> 
> -John C.
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
> 
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
> 
> 




More information about the talk mailing list