DB_common::commit()

DB_common::commit() – Commits the current transaction

Synopsis

mixed commit ( )

Description

Commits the current transaction.

Return value

integer - DB_OK on success or a DB_Error object on failure

Throws

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.

Note

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.

Example

Using commit()

<?php
// Once you have a valid DB object named $db...

$db->autoCommit(false);

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

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

$res =& $db->query('SELECT a FROM blah');
if (
DB::isError($res)) {
    echo 
$res->getMessage() . "\n";
}
while (
$res->fetchInto($rowDB_FETCHMODE_ORDERED)) {
    echo 
$row[0] . "\n";
}
$res->free();

$db->query('DROP TABLE blah');
$db->commit();
?>
Prepares an INSERT or UPDATE statement based on variables you supply (Previous) Creates a new sequence (Next)
Last updated: Tue, 02 Sep 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.