PDA

View Full Version : Diffrence between query_read and query_write?


alqassam
03-31-2009, 10:58 PM
Hello,
I want to know the diffrence between "query_read" and "query_write" commands??

I know i should use "query_read" for ("SELECT","SHOW") and "query_write" for ("INSERT","UPDATE","DELETE","REPLACE",... etc)

But when i revised the file "class_core.php" i found:

function query_read($sql, $buffered = true)
{
$this->sql =& $sql;
return $this->execute_query($buffered, $this->connection_master);
}

function query_write($sql, $buffered = true)
{
$this->sql =& $sql;
return $this->execute_query($buffered, $this->connection_master);
}


The same thing !!
what's the diffrence between them ? and can i use "query_read" for write queries and "query_write" for read queries?

Dismounted
04-01-2009, 07:03 AM
At the moment, there is no difference - there may be in the future, but there isn't any now. (Heck, you can have a look ay query() is you want to...)

You should use query_write() when writing data and query_read() when reading data.

Paul M
04-01-2009, 07:14 AM
Unless timing is vital, you should use query_read_slave() for reads.

alqassam
04-01-2009, 04:22 PM
Nice, I think it's better to make query_write() unbuffered query..
Thank you for the clarification

Antivirus
04-01-2009, 11:54 PM
also, one which I use quite frequently is query_first() which returns the first result within an array so you don't have to do db_fetch_array() after the query_read(). Very useful for when you know your query will only return one row

alqassam
04-02-2009, 10:33 AM
Thank you Antivirus,
Yes, it's also do free_result query