Evidently according to this: http://www.tuxradar.com/practicalphp/9/4/9
Between the time the call to mysql_unbuffered_query() is issued and your processing the last row, the table remains locked by MySQL and cannot be written to by other queries. If you plan to do lengthy processing on each row, this is not good.
So I'm trying to simulate that. Note that using MYSQLI_USE_RESULT is synonymous with using unbuffered query. Also note that there's around 60000 existing entries in the table.
So I have this code:
$use_buffer = FALSE;
$buffer = $use_buffer ? "SQL_BUFFER_RESULT" : "";
$query = "SELECT $buffer * FROM table";
$result = mysqli_query($db, $query, MYSQLI_USE_RESULT);
$inserted = FALSE;
$i = 0;
$rand = rand();
while($r = mysql_fetch_object($result)){
if(!$inserted){
mysqli_query($db, 'INSERT INTO table (something, somethingint) VALUES (\'NewValue' . $rand . '\', 1)');
print('INSERTEDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD');
$inserted = TRUE;
}
if(!($i % 500)){
$j = mysql_fetch_object(mysqli_query($db, "SELECT * FROM table WHERE something = 'NewValue$rand'"));
print_r($j);
print('still outputting');
print_r($r);
}
$i++;
if($i > 5000){
break;
}
}
mysql_free_result($result);
but then the code managed to insert new row into the table and moreover fetch that new table just fine even though the table is supposed to be locked until i'm done fetching all the rows.
Why is this happening? AM I missing something?