Rechercher une fonction PHP

mysqli::commit

mysqli_commit

(PHP 5, PHP 7)

mysqli::commit -- mysqli_commitCommits the current transaction

PHP: mysqli::commit - Manual Home of Manuel PHP  Contents Haut

Description

Object oriented style

mysqli::commit ([ int $flags = 0 [, string $name ]] ) : bool

Procedural style

mysqli_commit ( mysqli $link [, int $flags = 0 [, string $name ]] ) : bool

Commits the current transaction for the database connection.

PHP: mysqli::commit - Manual Home of Manuel PHP  Contents Haut

Parameters

link

Procedural style only: A link identifier returned by mysqli_connect() or mysqli_init()

flags

A bitmask of MYSQLI_TRANS_COR_* constants.

name

If provided then COMMIT/*name*/ is executed.

PHP: mysqli::commit - Manual Home of Manuel PHP  Contents Haut

Return Values

Returns TRUE on success or FALSE on failure.

PHP: mysqli::commit - Manual Home of Manuel PHP  Contents Haut

Changelog

Version Description
5.5.0 Added flags and name parameters.

PHP: mysqli::commit - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 mysqli::commit() example

Object oriented style

<?php
$mysqli 
= new mysqli("localhost""my_user""my_password""world");

/* check connection */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

$mysqli->query("CREATE TABLE Language LIKE CountryLanguage");

/* set autocommit to off */
$mysqli->autocommit(FALSE);

/* Insert some values */
$mysqli->query("INSERT INTO Language VALUES ('DEU', 'Bavarian', 'F', 11.2)");
$mysqli->query("INSERT INTO Language VALUES ('DEU', 'Swabian', 'F', 9.4)");

/* commit transaction */
if (!$mysqli->commit()) {
    print(
"Transaction commit failed\n");
    exit();
}

/* drop table */
$mysqli->query("DROP TABLE Language");

/* close connection */
$mysqli->close();
?>

Procedural style

<?php
$link 
mysqli_connect("localhost""my_user""my_password""test");

/* check connection */
if (!$link) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

/* set autocommit to off */
mysqli_autocommit($linkFALSE);

mysqli_query($link"CREATE TABLE Language LIKE CountryLanguage");

/* Insert some values */
mysqli_query($link"INSERT INTO Language VALUES ('DEU', 'Bavarian', 'F', 11.2)");
mysqli_query($link"INSERT INTO Language VALUES ('DEU', 'Swabian', 'F', 9.4)");

/* commit transaction */
if (!mysqli_commit($link)) {
    print(
"Transaction commit failed\n");
    exit();
}

/* close connection */
mysqli_close($link);
?>

PHP: mysqli::commit - Manual Home of Manuel PHP  Contents Haut

See Also

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-mysqli.commit.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut