Re: assign mysql query to a variable first or not

From: Date: Wed, 07 Apr 2004 09:58:41 +0000
Subject: Re: assign mysql query to a variable first or not
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-182605@lists.php.net to get a copy of this message
Hello Andy, Wednesday, April 7, 2004, 4:09:59 AM, you wrote: AB> is it better to give the mysql query string to a variable AB> instead of directly doing it with mysql_query? AB> i.e. AB> $query="select * from table";//is this a better way? AB> $query=mysql_query("select * from table");//or is this way AB> //better? AB> mysql_query("select * from table");//not a good idea i dont think... Most people here probably use some kind of database abstraction layer already (ADOdb, a Pear lib, or a home-grown one, etc). While you are not doing this at the moment, if you hold the query in a string before passing to MySQL it means you could implement a database handler in the future with minimal code changes and not have to re-do every single query. There are other benefits, but that one strikes me as the most important at the moment. -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html

« previous php.general (#182605) next »