NYCPHP Meetup

NYPHP.org

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

Daniel Convissor danielc at analysisandsolutions.com
Wed Apr 2 12:49:50 EDT 2008


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.

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list