views:

136

answers:

1

According to the documentation at mysqli_use_result

One should not use mysqli_use_result() if a lot of processing on the client side is performed, since this will tie up the server and prevent other threads from updating any tables from which the data is being fetched.

Does this only pertain to myISAM tables or also for InnoDB?

+1  A: 

Just checked: MyISAM locks, InnoDB doesn't lock:

<?php
        $db = new mysqli() or die ("Cannot connect: " . mysqli_connect_error() . "\n");
        $query = "SELECT * FROM mytable";
        $db->real_query($query) or die ("Cannot fetch: $db->error\n");
        $result = $db->use_result() or die ("Cannot use result: $db->error\n");
        while($row = $result->fetch_row()) {
                print join("\t", $row) . "\n";
                usleep(1000000);
        }
?>

This locks:

UPDATE mytable /* isam */ SET myvalue = 'test' WHERE id = 100

This doesn't:

UPDATE mytable /* innodb */ SET myvalue = 'test' WHERE id = 100
Quassnoi