php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #73852 Deprecate and remove PDO::PARAM_NULL
Submitted: 2017-01-02 18:04 UTC Modified: 2021-08-09 11:26 UTC
From: dorin dot marcoci at gmail dot com Assigned:
Status: Suspended Package: PDO related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dorin dot marcoci at gmail dot com
New email:
PHP Version: OS:

 

 [2017-01-02 18:04 UTC] dorin dot marcoci at gmail dot com
Description:
------------
NULL is a state, not a type or a value.
Using it as argument in bindValue or bindParam is a non-sense.
Nulls should be set like $stmt->bindValue('param', NULL, PDO::PARAM_INT);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-06 18:34 UTC] cmb@php.net
-Type: Bug +Type: Feature/Change Request
 [2017-01-06 18:34 UTC] cmb@php.net
> Nulls should be set like $stmt->bindValue('param', NULL,
> PDO::PARAM_INT);

As PHP is a loosely typed language, I would expect that to bind 0
(zero) to :param. Anyhow, having PDO::PARAM_NULL is not a bug per
se, and deprecating and removing it would almost certainly require
an RFC, see <https://wiki.php.net/rfc/howto>.
 [2017-01-06 18:43 UTC] dorin dot marcoci at gmail dot com
Christoph, 

Please, see more on this subject here: https://github.com/php/php-src/commit/32b6154a61fae820386527f3019f8c5937fc5d27#commitcomment-20349204

I agree it require an RFC. But current implementation of PDO::PARAM_NULL as a type is really a bad approach. 

What to put in param this case? 

bindValue('param', 'string', PDO::PARAM_NULL);

bindValue('param', 0, PDO::PARAM_NULL); // if 0 can be casted as null, why not 1?

or 

bindValue('param', TRUE, PDO::PARAM_NULL); // Put a NULL here?
 [2017-10-24 08:31 UTC] kalle@php.net
-Package: PDO Core +Package: PDO related
 [2021-08-09 11:26 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2021-08-09 11:26 UTC] cmb@php.net
I suspend this ticket, until someone pursues the RFC process[1].

[1] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC