Re: [PHP-DB] Benefits of assigning query to variable

2002-07-31 Thread Gerard Samuel

Me personally, so I can echo out the variable to see if the query is 
making sense.  Look at it as a debugging...

Brian Graham wrote:

>Are there any benefits to assigning a query to a variable?
>
>
>
>  
>

-- 
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Benefits of assigning query to variable

2002-07-31 Thread Adam Royle

Yes, I see a few benefits.

1. It makes the code easier to read.
2. It makes the code easier to debug.

Imagine the following:

$sql = "SELECT * FROM tblName";
$result = mysql_query($sql);

Now if you want to print the sql and not do the select, you would simply add a line

$sql = "SELECT * FROM tblName";
test($sql);
$result = mysql_query($sql);

where the function "test" is:

function test($var){
echo $var;
exit();
}

The benefits are more evident when you have bigger sql queries, such as:

$sql = "INSERT INTO tblName SET
field1 = 'something1',
field2 = 'something2',
field3 = 'something3',
field4 = 'something4'";

$result = mysql_query($sql);

Hope that answers your question.
Adam



[PHP-DB] Benefits of assigning query to variable

2002-07-31 Thread Brian Graham

Are there any benefits to assigning a query to a variable?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php