MySQL Unbuffered Query Behavior Change

MySQL Unbuffered Query Behavior Change

am 14.03.2011 18:32:33 von Nicholas Williams

--001636e0b621639930049e74b28a
Content-Type: text/plain; charset=ISO-8859-1

I was previously on PHP 5.1.6 and was using the following code:


$dbr = mysql_unbuffered_query($query, $this->con);

while($row = mysql_fetch_array($dbr, $assoc ? MYSQL_ASSOC : MYSQL_NUM))

$this->result[] = $row;

$this->rows = mysql_num_rows($dbr);


It worked properly. The documentation at
http://www.php.net/manual/en/function.mysql-num-rows.php indicates that
mysql_num_rows won't return the correct result on unbuffered queries until
all of the rows had been fetched, but since I was looping through and
fetching all rows with mysql_fetch_array, it worked properly and wasn't a
problem.


I've upgraded to PHP 5.3.5 and now mysql_num_rows always returns 0. I am
fetching all rows before calling mysql_num_rows, just like the documentation
says to do, so mysql_num_rows should return the correct result. Why is it
not? Is the documentation wrong now (should it have been updated to say that
mysql_num_rows now NEVER works with unbuffered queries instead of saying you
have to fetch all rows first)? Is there a bug in PHP? Or am I doing
something wrong and it just coincidentally worked before?


Thanks,


Nick

--001636e0b621639930049e74b28a--