note 116303 added to pdo.rollback

From: Date: Tue, 09 Dec 2014 10:44:37 +0000
Subject: note 116303 added to pdo.rollback
Groups: php.notes 
Request: Send a blank email to php-notes+get-201096@lists.php.net to get a copy of this message
this can help you to use PDO::roolBack and PDO::commit: for example: i have a table in mysql database and table name is "tbl1" in tbl1 i have tow columns ("id"=>integer,"name"=>char(25)) also i have another table as tbl2 and exactly like tbl1 now see command: $link=new PDO("mysql:host=host;dbname=dbname", 'user', 'pass'); $query="INSERT INTO tbl1 (id, name) VALUES (12, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')"; $query2="INSERT INTO tbl2 (name) VALUES ('ali')"; $link->beginTransaction(); try{ $result = $link->exec($query); $result2 = $link->exec($query2); }catch(PDOException $e){ die($e->getMessage()); } if($result2 && $result){ $link->commit(); }else{ $link->rollBack(); } ---- Server IP: 72.52.91.14 Probable Submitter: 80.191.128.178 ---- Manual Page -- http://php.net/manual/en/pdo.rollback.php Edit -- https://master.php.net/note/edit/116303 Del: integrated -- https://master.php.net/note/delete/116303/integrated Del: useless -- https://master.php.net/note/delete/116303/useless Del: bad code -- https://master.php.net/note/delete/116303/bad+code Del: spam -- https://master.php.net/note/delete/116303/spam Del: non-english -- https://master.php.net/note/delete/116303/non-english Del: in docs -- https://master.php.net/note/delete/116303/in+docs Del: other reasons-- https://master.php.net/note/delete/116303 Reject -- https://master.php.net/note/reject/116303 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201096) next »