Skip to content

Instantly share code, notes, and snippets.

@hamaco
Created August 25, 2011 09:39
Show Gist options
  • Save hamaco/1170326 to your computer and use it in GitHub Desktop.
Save hamaco/1170326 to your computer and use it in GitHub Desktop.
MySQLのトランザクションが…… => @suin
<?php
$con1 = mysql_connect("127.0.0.1", "root", null, true); mysql_select_db("test_db", $con1);
$con2 = mysql_connect("127.0.0.1", "root", null, true); mysql_select_db("test_db", $con2);
mysql_query("CREATE TABLE test (id int)engine=InnoDB", $con1);
mysql_query("BEGIN", $con1);
mysql_query("INSERT INTO test VALUES(1)", $con1);
mysql_query("INSERT INTO test VALUES(2)", $con2);
mysql_query("ROLLBACK", $con1);
$result = mysql_query("SELECT * FROM test", $con1);
while ($row = mysql_fetch_assoc($result)) {
var_dump($row);
}
mysql_query("DROP TABLE test", $con1);
mysql_close($con1);
mysql_close($con2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment