(PHP 5, PHP 7)
mysqli::autocommit -- mysqli_autocommit — 锟津开伙拷乇毡锟斤拷锟斤拷锟斤拷菘锟斤拷锟斤拷拥锟斤拷远锟斤拷锟斤拷锟斤拷峤伙拷锟斤拷锟侥J�
锟斤拷锟斤拷锟斤拷锟斤拷锟�
$mode
) : bool锟斤拷锟教伙拷锟斤拷锟�
锟津开伙拷乇毡锟斤拷锟斤拷锟斤拷菘锟斤拷锟斤拷拥锟斤拷远锟斤拷锟斤拷锟斤拷峤伙拷锟斤拷锟侥J斤拷锟�
锟斤拷锟斤拷要确锟较碉拷前锟斤拷锟接碉拷锟皆讹拷锟斤拷锟斤拷锟结交状态锟斤拷锟斤拷执锟斤拷锟斤拷锟絊QL锟斤拷锟斤拷SELECT @@autocommit.
link
锟斤拷锟皆癸拷锟教伙拷锟斤拷式锟斤拷锟斤拷mysqli_connect() 锟斤拷 mysqli_init() 锟斤拷锟截碉拷锟斤拷锟接憋拷识锟斤拷
mode
Whether to turn on auto-commit or not.
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷
Note:
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷诓锟街э拷锟斤拷锟斤拷锟斤拷锟侥憋拷锟斤拷询锟斤拷锟斤拷效锟斤拷锟斤拷MyISAM锟斤拷 ISAM锟斤拷
Example #1 mysqli::autocommit() example
锟斤拷锟斤拷锟斤拷锟斤拷锟�
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* turn autocommit on */
$mysqli->autocommit(TRUE);
if ($result = $mysqli->query("SELECT @@autocommit")) {
$row = $result->fetch_row();
printf("Autocommit is %s\n", $row[0]);
$result->free();
}
/* close connection */
$mysqli->close();
?>
锟斤拷锟教伙拷锟斤拷锟�
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
if (!$link) {
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
exit();
}
/* turn autocommit on */
mysqli_autocommit($link, TRUE);
if ($result = mysqli_query($link, "SELECT @@autocommit")) {
$row = mysqli_fetch_row($result);
printf("Autocommit is %s\n", $row[0]);
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�
Autocommit is 1