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

Reply via email to