Rechercher une fonction PHP

cubrid_commit

(PECL CUBRID >= 8.3.0)

cubrid_commitCommit a transaction

Description

cubrid_commit ( resource $conn_identifier ) : bool

The cubrid_commit() function is used to execute commit on the transaction pointed by conn_identifier, currently in progress. Connection to the server is closed after the cubrid_commit() function is called; However, the connection handle is still valid.

In CUBRID PHP, auto-commit mode is disabled by default for transaction management. You can set it by using cubrid_set_autocommit(). You can get its status by using cubrid_get_autocommit(). Before you start a transaction, remember to disable the auto-commit mode.

PHP: cubrid_commit - Manual Home of Manuel PHP  Contents Haut

Parameters

conn_identifier

Connection identifier.

PHP: cubrid_commit - Manual Home of Manuel PHP  Contents Haut

Return Values

TRUE, when process is successful.

FALSE, when process is unsuccessful.

PHP: cubrid_commit - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 cubrid_commit() example

<?php
$conn 
cubrid_connect("localhost"33000"demodb""dba");

@
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;
cubrid_set_autocommit($conn,false);
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            

PHP: cubrid_commit - Manual Home of Manuel PHP  Contents Haut

See Also

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-function.cubrid-commit.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut