Is transaction needed when insert single line in mysql with InnoDB engine?
I used to use
<?php
$sql = "insert into test (owner) values ('owen')";
$db->autocommit(false);
if (!$db->query($sql))
$db->rollback();
else
$db->commit();
$db->close();
?>
However, today I run two insert php files in a same tables, without any
action. It is simple like:
<?php
$sql = "insert into test (owner) values ('owen')"; //the other php is the
same but replacing 'owen' to 'huhu'
for ($i = 0; $i < 100 * 1000; $i++) {
$db->query($sql);
}
$db->close();
?>
I run two php files in two different consoles. Then I got 200,000 records
without any error. Does that mean using transaction manually is really not
needed. As there are no conflicts.
No comments:
Post a Comment