Skip to content

Commit 255cfca

Browse files
committed
db2_last_insert_id() may return null
1 parent 1ab0aff commit 255cfca

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

ibm_db2.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,4 @@ function db2_getoption($resource, string $option): string|false {}
337337
/**
338338
* @param resource $resource
339339
*/
340-
function db2_last_insert_id($resource): string {}
340+
function db2_last_insert_id($resource): ?string {}

ibm_db2_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: e952caf6e14487291104ab1f1fdd7f268cc8a6bc */
2+
* Stub hash: 3cbc4e7e9448199bff07235c7abe69943e4d239d */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_db2_connect, 0, 0, 3)
55
ZEND_ARG_TYPE_INFO(0, database, IS_STRING, 0)
@@ -243,7 +243,7 @@ ZEND_END_ARG_INFO()
243243

244244
#define arginfo_db2_getoption arginfo_db2_get_option
245245

246-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_db2_last_insert_id, 0, 1, IS_STRING, 0)
246+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_db2_last_insert_id, 0, 1, IS_STRING, 1)
247247
ZEND_ARG_INFO(0, resource)
248248
ZEND_END_ARG_INFO()
249249

ibm_db2_legacy_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: e952caf6e14487291104ab1f1fdd7f268cc8a6bc */
2+
* Stub hash: 3cbc4e7e9448199bff07235c7abe69943e4d239d */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_db2_connect, 0, 0, 3)
55
ZEND_ARG_INFO(0, database)

tests/test_last_insert_id.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if ($conn) {
2222

2323
/* Checking when no insert has been executed. */
2424
$ret = db2_last_insert_id($conn);
25-
if($ret) {
25+
if (null !== $ret) {
2626
echo "Last Insert ID is : " . $ret . "\n";
2727
} else {
2828
echo "No Last insert ID.\n";
@@ -31,7 +31,7 @@ if ($conn) {
3131
/* Inserting many rows from VALUES clause */
3232
$stmt = db2_exec($conn, $insertMany);
3333
$ret = db2_last_insert_id($conn);
34-
if($ret) {
34+
if (null !== $ret) {
3535
echo "Last Insert ID is : " . $ret . "\n";
3636
} else {
3737
echo "No Last insert ID.\n";
@@ -40,7 +40,7 @@ if ($conn) {
4040
/* Checking for single row inserted. */
4141
$stmt = db2_exec($conn, $insertTable);
4242
$ret = db2_last_insert_id($conn);
43-
if($ret) {
43+
if (null !== $ret) {
4444
echo "Last Insert ID is : " . $ret . "\n";
4545
} else {
4646
echo "No Last insert ID.\n";
@@ -50,7 +50,7 @@ if ($conn) {
5050
for ($i = 0;$i < 5;$i++) {
5151
$stmt = db2_exec($conn, $insertTable);
5252
$ret = db2_last_insert_id($conn);
53-
if($ret) {
53+
if (null !== $ret) {
5454
echo "Last Insert ID is : " . $ret . "\n";
5555
} else {
5656
echo "No Last insert ID.\n";
@@ -78,7 +78,7 @@ if ($conn) {
7878

7979
$stmt = db2_exec($conn, $insertTable);
8080
$ret = db2_last_insert_id($conn);
81-
if($ret) {
81+
if (null !== $ret) {
8282
echo "Last Insert ID is : " . $ret . "\n";
8383
} else {
8484
echo "No Last insert ID.\n";

0 commit comments

Comments
 (0)