update : 2015.11.03
php.shukuma.com

검색:
 
 
Commits the current transaction

mysqli::commit

mysqli_commit

(PHP 5)

mysqli::commit -- mysqli_commitCommits the current transaction

설명

객체 기반 형식

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

절차식 형식

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

Commits the current transaction for the database connection.

인수

link

순차 형식 전용: mysqli_connect()mysqli_init()가 반환한 연결 식별자.

flags

A bitmask of MYSQLI_TRANS_COR_* constants.

name

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

반환값

성공 시 TRUE를, 실패 시 FALSE를 반환합니다.

변경점

버전 설명
5.5.0 Added flags and name parameters.

예제

Example #1 mysqli::commit() example

객체 기반 형식

<?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();
?>

절차식 형식

<?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);
?>

참고