sqlsrv_rollback

(No version information available, might only be in Git)

sqlsrv_rollbackRolls back a transaction that was begun with sqlsrv_begin_transaction()

Beschreibung

sqlsrv_rollback(resource $conn): bool

Rolls back a transaction that was begun with sqlsrv_begin_transaction() and returns the connection to auto-commit mode.

Parameter-Liste

conn

The connection resource returned by a call to sqlsrv_connect().

Rückgabewerte

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

Beispiele

Beispiel #1 sqlsrv_rollback() example

The following example demonstrates how to use sqlsrv_begin_transaction() together with sqlsrv_commit() and sqlsrv_rollback().

<?php
$serverName 
"serverName\sqlexpress";
$connectionInfo = array( "Database"=>"dbName""UID"=>"userName""PWD"=>"password");
$conn sqlsrv_connect$serverName$connectionInfo);
if( 
$conn === false ) {
    die( 
print_rsqlsrv_errors(), true ));
}

/* Begin the transaction. */
if ( sqlsrv_begin_transaction$conn ) === false ) {
     die( 
print_rsqlsrv_errors(), true ));
}

/* Initialize parameter values. */
$orderId 1$qty 10$productId 100;

/* Set up and execute the first query. */
$sql1 "INSERT INTO OrdersTable (ID, Quantity, ProductID)
         VALUES (?, ?, ?)"
;
$params1 = array( $orderId$qty$productId );
$stmt1 sqlsrv_query$conn$sql1$params1 );

/* Set up and execute the second query. */
$sql2 "UPDATE InventoryTable 
         SET Quantity = (Quantity - ?) 
         WHERE ProductID = ?"
;
$params2 = array($qty$productId);
$stmt2 sqlsrv_query$conn$sql2$params2 );

/* If both queries were successful, commit the transaction. */
/* Otherwise, rollback the transaction. */
if( $stmt1 && $stmt2 ) {
     
sqlsrv_commit$conn );
     echo 
"Transaction committed.<br />";
} else {
     
sqlsrv_rollback$conn );
     echo 
"Transaction rolled back.<br />";
}
?>

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.

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

Definition von Stored Procedures - eine Einführung

Stored Procedures sind vordefinierte SQL-Codeblöcke, die in einer Datenbank gespeichert sind und bei Bedarf aufgerufen werden können. ...

Bernie

Autor : ebiz-consult GmbH & Co. KG
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

What challenges PHP developers face?

What are some of the most challenging scenarios or technical pitfalls that a PHP developer might face, potentially leading to frustration or setba ...

Geschrieben von HoumirKinkar am 29.04.2024 12:08:24
Forum: PHP Developer Forum
What challenges PHP developers face?

What are some of the most challenging scenarios or technical pitfalls that a PHP developer might face, potentially leading to frustration or setba ...

Geschrieben von HoumirKinkar am 29.04.2024 12:02:28
Forum: PHP Developer Forum
MovieClip leeren (AS3)

Ich war wirklich besorgt um meine bachelorarbeit schreiben lassen​ (https://xn--ghostwriter-sterreich-sec.at/bachelorarbeit-schreiben-lassen/). ...

Geschrieben von Farebn am 26.04.2024 22:50:34
Forum: Grafik / Design / Flash ...
Berechnungen durchführen

Hallo liebe Forenmitglieder, meine erste frage ist zum Aufbau meiner kleinen Berechnungswebseite, nichts kommerzielles, soll nur eine Anwendung f ...

Geschrieben von matze511 am 21.04.2024 21:42:37
Forum: PHP Developer Forum