|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-04-13 08:06 UTC] christoph dot lukas at gmx dot net
Description:
------------
DB2-Client: 9.7
Informix Dynamic Server: 11.50
Trying to insert a row into a simple table which should contain null for a DATE column fails using dynamic SQL.
Reproduce code:
---------------
/**
CREATE TABLE test
(
id SERIAL NOT NULL,
text VARCHAR(20),
date DATE,
PRIMARY KEY (id)
)
*/
$dbh = new PDO("ibm:test");
$sql = 'INSERT INTO test (ID, TEXT, DATE) VALUES (1, "foobar", null)';
$stmt = $dbh->query($sql);
var_dump($stmt->errorInfo());
$sql = 'INSERT INTO test (ID, TEXT, DATE) VALUES (?, ?, ?)';
$stmt = $dbh->prepare($sql);
$stmt->bindValue(1, 2, PDO::PARAM_INT);
$stmt->bindValue(2, "foobar", PDO::PARAM_STR);
$stmt->bindValue(3, null, PDO::PARAM_STR);
$result = $stmt->execute();
var_dump($stmt->errorInfo());
Expected result:
----------------
Expected that two rows are inserted.
Expected Output:
array(3) {
[0]=>
string(5) "00000"
[1]=>
int(0)
[2]=>
string(24) " ((null)[0] at (null):0)"
}
array(3) {
[0]=>
string(5) "00000"
[1]=>
int(0)
[2]=>
string(24) " ((null)[0] at (null):0)"
}
Actual result:
--------------
The first row is inserted correctly while the second insert fails:
array(3) {
[0]=>
string(5) "00000"
[1]=>
int(0)
[2]=>
string(24) " ((null)[0] at (null):0)"
}
array(3) {
[0]=>
string(5) "07001"
[1]=>
int(-99999)
[2]=>
string(150) "[IBM][CLI Driver] CLI0100E Wrong number of parameters. SQLSTATE=07001 (SQLExecute[-99999] at /usr/src/redhat/BUILD/PDO_IBM-1.3.2/ibm_statement.c:986)"
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 22:00:01 2025 UTC |
Hi, Here is the patch for this bug. I will include this in future release: 566,573c566,592 < rc = SQLBindParameter(stmt_res->hstmt, curr->paramno + 1, < inputOutputType, param_res->ctype, < param_res->data_type, < param_res->param_size, < param_res->scale, < &((curr->parameter)->value.lval), < curr->max_value_len, < ¶m_res->transfer_length); --- > switch(param_res->data_type) { > case SQL_TYPE_DATE: > case SQL_DATETIME: > case SQL_TYPE_TIME: > case SQL_TYPE_TIMESTAMP: > param_res->transfer_length = SQL_NULL_DATA; > param_res->ctype = SQL_C_CHAR; > rc = SQLBindParameter(stmt_res->hstmt, curr->paramno + 1, > inputOutputType, param_res->ctype, > param_res->data_type, > param_res->param_size, > param_res->scale, NULL, > curr->max_value_len <= > 0 ? 0 : curr->max_value_len, > ¶m_res->transfer_length); > break; > > default: > rc = SQLBindParameter(stmt_res->hstmt, curr->paramno + 1, > inputOutputType, param_res->ctype, > param_res->data_type, > param_res->param_size, > param_res->scale, > &((curr->parameter)->value.lval), > curr->max_value_len, > ¶m_res->transfer_length); > } 585a605 > Regards, Ambrish Bhargava