rfc:deprecate_pdo_null

PHP RFC: Deprecate PDO::PARAM_NULL

Introduction

PDO defines a NULL type, but this concept is not part of the SQL standard. Types are nullable, but there is no type that can only have that value.

The presence of this type is potentially confusing to users. Supporting it adds some weight to PDO. A handful of people on the internals mail list have asked for it to be removed.

Proposal

Uses of PDO::PARAM_NULL in the next PHP 7.x would result in deprecation notices. The const and related code would be removed in PHP 7.x+1.

Notices could be produced by these methods:

  • PDO::quote
  • PDOStatement::bindColumn
  • PDOStatement::bindParam
  • PDOStatement::bindValue

None of the supported PDO drivers rely on this type to bind null values. It's functionally equivalent to use null with any of the other types. I found four drivers on Pecl with PHP7 support: msphpsql, pdo_ibm, pdo_informix, pdo_sqlanywhere. Some will require modifications to compile once this const is removed, but they won't lose functionality either.

Put another way, any code like this:

$statement->bindValue(1, null, PDO::PARAM_NULL);

Can be replaced by this:

$statement->bindValue(1, null);

Proposed Voting Choices

This project requires a 50%+1 majority.

rfc/deprecate_pdo_null.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1