php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56367 Can't insert null values into table
Submitted: 2005-04-04 16:52 UTC Modified: 2005-07-08 19:15 UTC
From: gpd at gpdnet dot co dot uk Assigned:
Status: Closed Package: PDO_ODBC (PECL)
PHP Version: 5_1 CVS-2005-04-04 (dev) OS: Windows XP
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: gpd at gpdnet dot co dot uk
New email:
PHP Version: OS:

 

 [2005-04-04 16:52 UTC] gpd at gpdnet dot co dot uk
Description:
------------
Using bindParam and named arguments in an insert statement or stored procedure call I can't find a way of inserting or updating fields with a null value.

I think I am using the correct code below according to the PDO documentation

I've tried various combinations of values and parameters, but I can't get it to insert a null value.

Reproduce code:
---------------
SQL:
create table test (c1 int, c2 int);
---------
PHP:
$cn = new PDO('odbc:DRIVER={Adaptive Server Anywhere 9.0};ENG=webroster;DBN=cct8740;CommLinks=TCP','dba','sql');

//sleep(30);
$dr = $cn->prepare('insert into test(c1,c2) values(:c1, :c2)');
$val1 = 1;
$val2 = 2;
$dr->bindParam(':c1',$val1,PDO_PARAM_INT);
$dr->bindParam(':c2',$val2,PDO_PARAM_NULL);
$dr->execute();


Expected result:
----------------
values 1 and null in the test table

Actual result:
--------------
values 1 and 2 in the test table

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-24 17:15 UTC] saruman at unigsm dot com
It seems that you'll get NULL in table only when $val2 === NULL:

---
$val1 = 1;
$val2 = NULL;
$dr->bindParam(':c1',$val1,PDO_PARAM_INT);
$dr->bindParam(':c2',$val2,PDO_PARAM_NULL);
$dr->execute();
---
 [2005-06-24 17:30 UTC] gpd at gpdnet dot co dot uk
I did actually try that at the time and several other combinations as well. Did you try this code and sucessfully get a null value in the database?

I can't try it at the moment as the odbc driver seems to be missing from recent snapshots (already reported).
 [2005-07-08 13:10 UTC] wez@php.net
Should be fixed in the latest snap.
 [2005-07-08 19:15 UTC] gpd at gpdnet dot co dot uk
Tested and verified as fixed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC