国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

I set up the transaction mechanism and deliberately set the second sql statement to be wrong. Why was the first sql statement executed in the end? Shouldn't the transaction be rolled back and not executed at all?
陳老師
陳老師 2018-05-19 12:55:01
0
1
1307


<?php

$pdo=new PDO('mysql:host=localhost;dbname=student','root','root');

try{

$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$pdo->beginTransaction();

//The first sql statement

$sqla="delete from chen where id=14";

$pdo->exec($sqla) ;

//The sql statement on the second day

$sqlb="delete froms chen where id=15"; //The from is written incorrectly on purpose

$pdo->exec($sqlb);


}catch(Exception $e){

$pdo ->rollBack();

$e->getMessage();

echo "Operation failed";

}

?>


陳老師
陳老師

reply all(1)
NULL

Is the database engine MyISAM? Try changing it to InnoDB

  • reply Yes, I found the problem. Thank you very much. Awesome.
    陳老師 author 2018-05-21 10:55:46
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template