php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59156 bind NULL Values to DATE columns does not work
Submitted: 2010-04-13 08:06 UTC Modified: 2011-09-02 04:59 UTC
From: christoph dot lukas at gmx dot net Assigned:
Status: Closed Package: PDO_IBM (PECL)
PHP Version: 5.2.13 OS: Linux CentOS 5.4
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: christoph dot lukas at gmx dot net
New email:
PHP Version: OS:

 

 [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)"
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-19 04:18 UTC] abhargav at in dot ibm dot com
Hi,

I will analyze the issue and will update you.

Regards,
Ambrish Bhargava
 [2010-11-30 04:27 UTC] abhargav at in dot ibm dot com
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,
< 						&param_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,
> 								&param_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,
> 								&param_res->transfer_length);
> 				}
585a605
> 


Regards,
Ambrish Bhargava
 [2011-09-02 04:59 UTC] abhargav at in dot ibm dot com
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

Hi,

This is fixed in SVN.

Regards,
Ambrish Bhargava
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 11:01:27 2024 UTC