cubrid_rollback
(PECL CUBRID >= 8.3.0)
cubrid_rollback — Roll back a transaction
Description
bool cubrid_rollback
( resource
$conn_identifier
)
The cubrid_rollback() function executes rollback on the
transaction pointed by conn_identifier
, currently in
progress.
Connection to server is closed after calling cubrid_rollback(). Connection handle, however, is still valid.
Parameters
-
conn_identifier
-
Connection identifier.
Return Values
TRUE
, when process is successful.
FALSE
, when process is unsuccessful.
Examples
Example #1 cubrid_rollback() example
<?php
$conn = cubrid_connect("127.0.0.1", 33000, "demodb", "dba");
cubrid_set_autocommit($conn,false);
@cubrid_execute($conn, "DROP TABLE publishers");
$sql = <<<EOD
CREATE TABLE publishers(
pub_id CHAR(3),
pub_name VARCHAR(20),
city VARCHAR(15),
state CHAR(2),
country VARCHAR(15)
)
EOD;
if (!cubrid_execute($conn, $sql)) {
printf("Error facility: %d\nError code: %d\nError msg: %s\n", cubrid_error_code_facility(), cubrid_error_code(), cubrid_error_msg());
cubrid_disconnect($conn);
exit;
}
$req = cubrid_prepare($conn, "INSERT INTO publishers VALUES(?, ?, ?, ?, ?)");
$id_list = array("P01", "P02", "P03", "P04");
$name_list = array("Abatis Publishers", "Core Dump Books", "Schadenfreude Press", "Tenterhooks Press");
$city_list = array("New York", "San Francisco", "Hamburg", "Berkeley");
$state_list = array("NY", "CA", NULL, "CA");
$country_list = array("USA", "USA", "Germany", "USA");
for ($i = 0, $size = count($id_list); $i < $size; $i++) {
cubrid_bind($req, 1, $id_list[$i]);
cubrid_bind($req, 2, $name_list[$i]);
cubrid_bind($req, 3, $city_list[$i]);
cubrid_bind($req, 4, $state_list[$i]);
cubrid_bind($req, 5, $country_list[$i]);
if (!($ret = cubrid_execute($req))) {
break;
}
}
if (!$ret) {
cubrid_rollback($conn);
} else {
cubrid_commit($conn);
$req = cubrid_execute($conn, "SELECT * FROM publishers");
while ($result = cubrid_fetch_assoc($req)) {
printf("%-3s %-20s %-15s %-3s %-15s\n",
$result["pub_id"], $result["pub_name"], $result["city"], $result["state"], $result["country"]);
}
}
cubrid_disconnect($conn);
?>
The above example will output:
P01 Abatis Publishers New York NY USA P02 Core Dump Books San Francisco CA USA P03 Schadenfreude Press Hamburg Germany P04 Tenterhooks Press Berkeley CA USA
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- CUBRID
- cubrid_bind
- cubrid_close_prepare
- cubrid_close_request
- cubrid_col_get
- cubrid_col_size
- cubrid_column_names
- cubrid_column_types
- cubrid_commit
- cubrid_connect_with_url
- cubrid_connect
- cubrid_current_oid
- cubrid_disconnect
- cubrid_drop
- cubrid_error_code_facility
- cubrid_error_code
- cubrid_error_msg
- cubrid_execute
- cubrid_fetch
- cubrid_free_result
- cubrid_get_autocommit
- cubrid_get_charset
- cubrid_get_class_name
- cubrid_get_client_info
- cubrid_get_db_parameter
- cubrid_get_query_timeout
- cubrid_get_server_info
- cubrid_get
- cubrid_insert_id
- cubrid_is_instance
- cubrid_lob_close
- cubrid_lob_export
- cubrid_lob_get
- cubrid_lob_send
- cubrid_lob_size
- cubrid_lob2_bind
- cubrid_lob2_close
- cubrid_lob2_export
- cubrid_lob2_import
- cubrid_lob2_new
- cubrid_lob2_read
- cubrid_lob2_seek64
- cubrid_lob2_seek
- cubrid_lob2_size64
- cubrid_lob2_size
- cubrid_lob2_tell64
- cubrid_lob2_tell
- cubrid_lob2_write
- cubrid_lock_read
- cubrid_lock_write
- cubrid_move_cursor
- cubrid_next_result
- cubrid_num_cols
- cubrid_num_rows
- cubrid_pconnect_with_url
- cubrid_pconnect
- cubrid_prepare
- cubrid_put
- cubrid_rollback
- cubrid_schema
- cubrid_seq_drop
- cubrid_seq_insert
- cubrid_seq_put
- cubrid_set_add
- cubrid_set_autocommit
- cubrid_set_db_parameter
- cubrid_set_drop
- cubrid_set_query_timeout
- cubrid_version
Коментарии
404 Not Found