php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67053 php-mysqlnd returns 0 value on insert
Submitted: 2014-04-10 07:42 UTC Modified: 2014-04-10 09:54 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: r dot bohnen at ips dot nl Assigned:
Status: Closed Package: MySQLi related
PHP Version: 5.5.11 OS: CentOS release 6.5 (Final)
Private report: No CVE-ID: None
 [2014-04-10 07:42 UTC] r dot bohnen at ips dot nl
Description:
------------
When you insert and row within MySQL with the php-mysqlnd library you'll get an empty result set as result.
Expected is; Inserted row id: {row number}
Current is; MySQL returned an empty result set (i.e. zero rows). (Query took 0.0002 sec)

Which means when you use:
mysqli_query("INSERT INTO demo (demoid,demoname,demovalue) VALUES ('','name','value')");
and you want to have the inserted id (with mysqli_insert_id();) you will get NULL or 0 response, that's incorrect. 

When we use an older php-mysql or php-mysqlnd library than 5.5.10 (now using 5.5.11 and tried with 5.5.10, but that's also broken) it works as expected.

Tested on multiple servers with same configuration.

Test script:
---------------
<?php
$query = mysqli_query("INSERT INTO demo (demoid,demoname,demovalue) VALUES ('','name','value')");
$result = mysqli_insert_id();

echo $result;

Expected result:
----------------
Returned ID

Actual result:
--------------
Null or 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-10 07:48 UTC] r dot bohnen at ips dot nl
It's only at the second insert, the first is ok and as expected.
 [2014-04-10 07:53 UTC] requinix@php.net
-Status: Open +Status: Feedback -Package: MySQL related +Package: MySQLi related
 [2014-04-10 07:53 UTC] requinix@php.net
Need a new repro script, since the first one won't work and doesn't match your updated description.
 [2014-04-10 09:54 UTC] r dot bohnen at ips dot nl
-Status: Feedback +Status: Closed
 [2014-04-10 09:54 UTC] r dot bohnen at ips dot nl
Cannot reproduce it anymore. Seems to be an phpmyadmin issue instead.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC