Last active
August 28, 2015 02:33
-
-
Save phpdave/7383edd195450da3e6df to your computer and use it in GitHub Desktop.
Handling the DB2 record lock exception in PHP when updating a record that has a lock.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
try | |
{ | |
$user="BOB"; | |
$id="2"; | |
$db=new PDO("ReplceW/ConnectionString"); | |
$stmt=$db->prepare("UPDATE `users` SET user=:user WHERE ID =:ID"); | |
$stmt->bindParam(":user",$user); | |
$stmt->bindParam(":id",$id); | |
$stmt->execute(); | |
} | |
catch (Exception $exception) | |
{ | |
//Lets handle the exception of a record lock | |
//SQLSTATE[HY000]: General error: -913 [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0913 - Row or object TABLE in LIB type *FILE in use. | |
if (strpos($exception->getMessage(),'SQL0913') !== false) { | |
//There's a file lock do what you want to do to handle this situation | |
$record->putOnHold(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment