Database result resource - detail?
Posted: Mon Jun 17, 2002 4:34 am
When use a database connection to execute a select statement and it succeeds in returning the result set, what exactly has it returned to PHP?
If I execute a command like
$result=mysql_query("Select * FROM USERS");
then I can fetch one row at a time from $result - for example with:
$row=mysql_fetch_array($result);
And each time I issue the fetch command I will get the next row, and there are functions to move the pointer or reset back to the beginning.
My question: Is the entire result in PHP memory? Or is the result set a temporary table on the database server? In other words does the PHP result set just point to the database? Or can I close the connection and still continue to get the fetch rows from result?
Also I assume that even if it is a pointer it is a static result set. That is if someone updates or deletes one of the records my select statement retrieved, that this will not be reflected in my result set $result.
OK - I know this was not put in the most succinct manner possible; but I wanted to be clear on what I already knew, what I question was, and what I knew that might not be so.
If I execute a command like
$result=mysql_query("Select * FROM USERS");
then I can fetch one row at a time from $result - for example with:
$row=mysql_fetch_array($result);
And each time I issue the fetch command I will get the next row, and there are functions to move the pointer or reset back to the beginning.
My question: Is the entire result in PHP memory? Or is the result set a temporary table on the database server? In other words does the PHP result set just point to the database? Or can I close the connection and still continue to get the fetch rows from result?
Also I assume that even if it is a pointer it is a static result set. That is if someone updates or deletes one of the records my select statement retrieved, that this will not be reflected in my result set $result.
OK - I know this was not put in the most succinct manner possible; but I wanted to be clear on what I already knew, what I question was, and what I knew that might not be so.