cubrid_rollback

(PECL CUBRID >= 8.3.0)

cubrid_rollbackRoll back a transaction

Description

cubrid_rollback(resource $conn_identifier): bool

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

Returns true on success or false on failure.

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($req1$id_list[$i]);
    
cubrid_bind($req2$name_list[$i]);
    
cubrid_bind($req3$city_list[$i]);
    
cubrid_bind($req4$state_list[$i]);
    
cubrid_bind($req5$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            

See Also

Here you can write a comment


Please enter at least 10 characters.
Loading... Please wait.
* Pflichtangabe
There are no comments available yet.

Midjourney Tutorial - Instructions for beginners

There is an informative video about Midjourney, the tool for creating digital images using artificial intelligence, entitled "Midjourney tutorial in German - instructions for beginners" ...

Mike94

Autor : Mike94
Category: KI Tutorials

Basics of views in MySQL

Views in a MySQL database offer the option of creating a virtual table based on the result of an SQL query. This virtual table can be queried like a normal table without changing the underlying data. ...

admin

Autor : admin
Category: mySQL-Tutorials

Definition of stored procedures - an introduction

Stored procedures are predefined SQL code blocks that are stored in a database and can be called up as required. ...

Bernie

Autor : ebiz-consult GmbH & Co. KG
Category: mySQL-Tutorials

Publish a tutorial

Share your knowledge with other developers worldwide

Share your knowledge with other developers worldwide

You are a professional in your field and want to share your knowledge, then sign up now and share it with our PHP community

learn more

Publish a tutorial