Skip to content

db2_last_insert_id() may return null #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ibm_db2.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,4 @@ function db2_getoption($resource, string $option): string|false {}
/**
* @param resource $resource
*/
function db2_last_insert_id($resource): string {}
function db2_last_insert_id($resource): ?string {}
4 changes: 2 additions & 2 deletions ibm_db2_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: e952caf6e14487291104ab1f1fdd7f268cc8a6bc */
* Stub hash: 3cbc4e7e9448199bff07235c7abe69943e4d239d */

ZEND_BEGIN_ARG_INFO_EX(arginfo_db2_connect, 0, 0, 3)
ZEND_ARG_TYPE_INFO(0, database, IS_STRING, 0)
Expand Down Expand Up @@ -243,7 +243,7 @@ ZEND_END_ARG_INFO()

#define arginfo_db2_getoption arginfo_db2_get_option

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_db2_last_insert_id, 0, 1, IS_STRING, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_db2_last_insert_id, 0, 1, IS_STRING, 1)
ZEND_ARG_INFO(0, resource)
ZEND_END_ARG_INFO()

Expand Down
2 changes: 1 addition & 1 deletion ibm_db2_legacy_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: e952caf6e14487291104ab1f1fdd7f268cc8a6bc */
* Stub hash: 3cbc4e7e9448199bff07235c7abe69943e4d239d */

ZEND_BEGIN_ARG_INFO_EX(arginfo_db2_connect, 0, 0, 3)
ZEND_ARG_INFO(0, database)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_last_insert_id.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if ($conn) {

/* Checking when no insert has been executed. */
$ret = db2_last_insert_id($conn);
if($ret) {
if (null !== $ret) {
echo "Last Insert ID is : " . $ret . "\n";
} else {
echo "No Last insert ID.\n";
Expand All @@ -31,7 +31,7 @@ if ($conn) {
/* Inserting many rows from VALUES clause */
$stmt = db2_exec($conn, $insertMany);
$ret = db2_last_insert_id($conn);
if($ret) {
if (null !== $ret) {
echo "Last Insert ID is : " . $ret . "\n";
} else {
echo "No Last insert ID.\n";
Expand All @@ -40,7 +40,7 @@ if ($conn) {
/* Checking for single row inserted. */
$stmt = db2_exec($conn, $insertTable);
$ret = db2_last_insert_id($conn);
if($ret) {
if (null !== $ret) {
echo "Last Insert ID is : " . $ret . "\n";
} else {
echo "No Last insert ID.\n";
Expand All @@ -50,7 +50,7 @@ if ($conn) {
for ($i = 0;$i < 5;$i++) {
$stmt = db2_exec($conn, $insertTable);
$ret = db2_last_insert_id($conn);
if($ret) {
if (null !== $ret) {
echo "Last Insert ID is : " . $ret . "\n";
} else {
echo "No Last insert ID.\n";
Expand Down Expand Up @@ -78,7 +78,7 @@ if ($conn) {

$stmt = db2_exec($conn, $insertTable);
$ret = db2_last_insert_id($conn);
if($ret) {
if (null !== $ret) {
echo "Last Insert ID is : " . $ret . "\n";
} else {
echo "No Last insert ID.\n";
Expand Down