note 98361 added to function.db2-last-insert-id
| From: | MarkAdkins at osu1 dot php dot net | Date: | Thu, 10 Jun 2010 16:28:47 +0000 |
| Subject: | note 98361 added to function.db2-last-insert-id | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170027@lists.php.net to get a copy of this message | ||
On the iSeries and maybe other db2 platforms, this function is not defined--PHP Fatal error: Call
to undefined function db2_last_insert_id().
The alternative is to use IDENTITY_VAL_LOCAL().
The above example becomes:
<?php
$database = "SAMPLE";
$user = "db2inst1";
$password = "ibmdb2";
$conn = db2_connect($database, $user, $password);
if($conn) {
$createTable = "CREATE TABLE lastInsertID
(id integer GENERATED BY DEFAULT AS IDENTITY, name varchar(20))";
$insertTable = "INSERT INTO lastInsertID (name) VALUES ('Temp Name')";
$getIdentity = "SELECT IDENTITY_VAL_LOCAL() AS LASTID FROM SYSIBM.SYSDUMMY1";
$stmt = @db2_exec($conn, $createTable);
/* Checking for single row inserted. */
$stmt = db2_exec($conn, $insertTable);
$stmt = db2_exec($conn, $getIdentity);
$row = db2_fetch_assoc($stmt);
$ret = $row['LASTID'];
if($ret) {
echo "Last Insert ID is : " . $ret . "\n";
} else {
echo "No Last insert ID.\n";
}
db2_close($conn);
}
else {
echo "Connection failed.";
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 66.142.7.6
----
Manual Page -- http://www.php.net/manual/en/function.db2-last-insert-id.php
Edit -- https://master.php.net/note/edit/98361
Del: integrated -- https://master.php.net/note/delete/98361/integrated
Del: useless -- https://master.php.net/note/delete/98361/useless
Del: bad code -- https://master.php.net/note/delete/98361/bad+code
Del: spam -- https://master.php.net/note/delete/98361/spam
Del: non-english -- https://master.php.net/note/delete/98361/non-english
Del: in docs -- https://master.php.net/note/delete/98361/in+docs
Del: other reasons-- https://master.php.net/note/delete/98361
Reject -- https://master.php.net/note/reject/98361
Search -- https://master.php.net/manage/user-notes.php