Bug #62024 [Com]: Cannot insert second row with null using parametrized query (Firebird PDO)
| From: | matheus at gigatron dot com dot br | Date: | Thu, 21 Mar 2013 19:05:18 +0000 |
| Subject: | Bug #62024 [Com]: Cannot insert second row with null using parametrized query (Firebird PDO) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-177973@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62024&edit=1
ID: 62024
Comment by: matheus at gigatron dot com dot br
Reported by: matheus at gigatron dot com dot br
Summary: Cannot insert second row with null using
parametrized query (Firebird PDO)
Status: Open
Type: Bug
Package: PDO related
Operating System: Windows 7
PHP Version: 5.4.3
Block user comment: N
Private report: N
New Comment:
I can confirm James' patch indeed seems to solve the problem (at least for this reproducible
test script).
Would be nice if a developer could include this on the master php branch.
Previous Comments:
------------------------------------------------------------------------
[2012-05-27 10:59:42] mr dot efrem at gmail dot com
This problem is observed still in php5-5.3.13.
------------------------------------------------------------------------
[2012-05-14 13:35:08] matheus at gigatron dot com dot br
Description:
------------
Using the firebird PDO driver and a parametrized insert query, you cannot use a null value for a
column after issuing a query with a filled value for that same column.
On the snipped below, it should be possible to insert both rows, but the second one fails with an
exception. If you invert the order of the inserts (insert $args_err before $args_ok) then the script
runs.
Test script:
---------------
/**Reference table:
CREATE TABLE TEST_INSERT (
ID INTEGER NOT NULL,
COL1 VARCHAR(40)
);
*/
$sql = "insert into test_insert (id, col1) values (?, ?);"
$args_ok = [1, "test1"];
$args_err = [2, null];
$res = $stmt->execute($args_ok);
var_dump($res);
$res = $stmt->execute($args_err);
var_dump($res);
Expected result:
----------------
bool(true)
bool(true)
Actual result:
--------------
bool(true)
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY105
]: Invalid parameter type: -999 Parameter requires non-null value' in F:\demos\p
hp\erro_insert_prep_null\test.php:42
Stack trace:
#0 F:\demos\php\erro_insert_prep_null\test.php(42): PDOStatement->execute(Array)
#1 {main}
thrown in F:\demos\php\erro_insert_prep_null\test.php on line 42
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62024&edit=1