DB_common::autoCommit() – Turns auto-commit on or off


mixed autoCommit ( boolean $onoff = false )


Turns auto-commit on or off.


boolean $onoff

TRUE to turn auto-commit on. FALSE to turn auto-commit off.

Return value

integer - DB_OK on success or a DB_Error object on failure


Possible PEAR_Error values
Error code Error message Reason Solution
every other error code   Database specific error Check the database related section of PHP-Manual to detect the reason for this error.


This function can not be called statically.

When using MySQL as your DBMS, transactions can only be used when the tables in question use the InnoDB format.


Using autocommit()

=& DB::connect('ibase(firebird)://user:pw@localhost/path/file');


$db->query('CREATE TABLE blah (a integer)');
$db->query('CREATE TABLE blue (b integer)');

$db->query('INSERT INTO blah (a) VALUES (11)');
$db->query('INSERT INTO blah (a) VALUES (12)');

$res1 =& $db->query('SELECT a FROM blah');
if (
DB::isError($res1)) {
$res1->getMessage() . "\n";
$i 1;
while (
$res1->fetchInto($rowDB_FETCHMODE_ORDERED)) {
"fetch data $row[0]\n";
"insert number $i...\n";
$res2 =& $db->query("INSERT INTO blue (b) VALUES ($i)");
    if (
DB::isError($res2)) {
$res2->getMessage() . "\n";

$db->query('DROP TABLE blah');
$db->query('DROP TABLE blue');
Finds number of rows affected by a data changing query (Previous) Prepares and runs an INSERT or UPDATE query based on variables you supply (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.