in reply to Re^3: turning off Autocommit (MySql)
in thread turning off Autocommit (MySql)
But somehow it didn't work, the row is inserted anyway#! /usr/bin/perl use DBI ; $root = "root" ; $dbc = "dbi:mysql::localhost" ; $dbh = DBI->connect($dbc, $root, $passwd, {AutoCommit => 0, RaiseError + => 1}) ; $dbh->{'AutoCommit'} = 0 ; $dbh->do("CREATE DATABASE xxx") ; $dbh->do("USE xxx") ; $dbh->do("CREATE TABLE test (str VARCHAR(50))") ; $str = "INSERT INTO test SET str='hello'" ; $sth = $dbh->prepare($str) ; $r = $sth->execute() ; if (! $r) { print "could not insert\n" ; } else { print "ok\n" ; $dbh->rollback() ; } $dbh->disconnect() ;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: turning off Autocommit (MySql)
by tirwhan (Abbot) on Nov 11, 2005 at 15:38 UTC | |
by jeanluca (Deacon) on Nov 11, 2005 at 15:49 UTC | |
by tirwhan (Abbot) on Nov 11, 2005 at 16:01 UTC | |
by jeanluca (Deacon) on Nov 11, 2005 at 16:00 UTC |