note 74507 added to function.PDO-rollBack
| From: | emalinks at gmail dot com | Date: | Sat, 14 Apr 2007 20:09:56 +0000 |
| Subject: | note 74507 added to function.PDO-rollBack | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125401@lists.php.net to get a copy of this message | ||
<?php
//run this on your latest PHP let me know if it doesn't fail
//to test this program u must run it twice at the same time in ie. two terminals
//this program suposedly creates a new dbase with table name NodeNames and one field in it named
NodeName
//it then begins a transaction then attempts to read an element 'zTest' of field
'NodeName' which obv. doesn't exist, ignoring the returned errors
//then it writes it(since it wasn't there)
//then decides to rollBack the transaction and eventually try a new one
//because rollBack doesn't really work(apparently) for some unknown reason, beginTransaction
fails saying 'There is already an active transaction'
$db = new PDO('sqlite:demlinks6.3sql',''/*user*/,''/*pwd*/);
$db->exec('CREATE TABLE \'NodeNames\' ("NodeName" VARCHAR(10));');
$db->beginTransaction();
$getter="zTest";
$pgn = $db->prepare('SELECT * FROM \'NodeNames\' WHERE "NodeName" =
:node13');
$pgn->bindParam(":node13", $getter, PDO::PARAM_STR);
//read
$pgn->execute();//execute above SELECT
$ar=$pgn->FetchAll();//get array of results
$writter="zTest";
$pnn=$db->prepare('INSERT INTO \'NodeNames\' ("NodeName") VALUES
(:node14)');
$pnn->bindParam(":node14", $writter, PDO::PARAM_STR);
//write
$pnn->execute();//write it!
echo "waiting...";
usleep(2000000);
echo "done\n";
$db->rollBack();//this doesn't do it's job
$db->beginTransaction();//here it fails, when running this program twice at the same time;
'There is already an active transaction'
//unreachable:
$db->commit();
?>
----
Server IP: 69.147.83.197
Probable Submitter: 86.35.66.94
----
Manual Page -- http://www.php.net/manual/en/function.PDO-rollBack.php
Edit -- https://master.php.net/note/edit/74507
Del: integrated -- https://master.php.net/note/delete/74507/integrated
Del: useless -- https://master.php.net/note/delete/74507/useless
Del: bad code -- https://master.php.net/note/delete/74507/bad+code
Del: spam -- https://master.php.net/note/delete/74507/spam
Del: non-english -- https://master.php.net/note/delete/74507/non-english
Del: in docs -- https://master.php.net/note/delete/74507/in+docs
Del: other reasons-- https://master.php.net/note/delete/74507
Reject -- https://master.php.net/note/reject/74507
Search -- https://master.php.net/manage/user-notes.php