cubrid_commit

(PECL CUBRID >= 8.3.0)

cubrid_commitCommit a transaction

Beschreibung

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.

Parameter-Liste

conn_identifier

Connection identifier.

Rückgabewerte

Gibt bei Erfolg true zurück. Bei einem Fehler wird false zurückgegeben.

Beispiele

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

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

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            

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

SoundCloud to MP3

SoundCloud (https://soundcloudto.com/) to MP3 converters have gained popularity as convenient tools for downloading and converting audio from Soun ...

Geschrieben von soundcloudto am 19.07.2024 04:10:40
Forum: User pages
Suche Netzwerktechnik Großhändler

I'm currently seeking reliable wholesalers specializing in network technology. Please provide details on your range of products, pricing, and any ...

Geschrieben von dussan77 am 12.07.2024 16:54:48
Forum: Ankündigungen
Getting Database Connection Failed Error in PHP Project

Hi everyone, I’m currently working on an AI and ML-based web application using PHP, and I've hit a roadblock. I’m encountering a “Database ...

Geschrieben von Gast am 27.06.2024 11:31:32
Forum: Off-Topic Diskussionen
How to overcome Safari's iframe cookie block?

Hello I think your cookies are set with SameSite=None; Secure to allow cross-site usage. To implement a custom proxy on the server side to handle ...

Geschrieben von Gast am 27.06.2024 11:04:46
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS