出售域名  LinuxTags


mysqli_commit

mysqli->commit()

(PHP 5)

mysqli->commit() — Commits the current transaction

说明

Procedural style:

bool mysqli_commit ( mysqli $link )

Object oriented style (method)

mysqli
bool commit ( void )

Commits the current transaction for the database connection.

参数

link

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

返回值

如果成功则返回 TRUE,失败则返回 FALSE

范例

Example#1 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 Type=InnoDB");

/* 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 */
$mysqli->commit();

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

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

Example#2 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 Type=InnoDB");

/* 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 */
mysqli_commit($link);

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


出售域名  LinuxTags