Autocommit with PDO
问题 The rollback of my transaction doesn't work. How do I set autocommit to false (or 0) in the php script using PDO (I have InnoDB 5.7.18) ? Here is my code: global $bdd; //defined with PDO try { $bdd->beginTransaction(); /* my requests */ $bdd->commit(); } catch (Exception $e) { $bdd->rollBack(); return $e->getMessage(); } return true; } 回答1: $db = new PDO('mysql:dbname=employee'); $db->setAttribute(PDO::ATTR_AUTOCOMMIT,0); var_dump($db->query('SELECT @@autocommit')->fetchAll()); 回答2: I solved