Skip to content

PHP 7.2 extended string types support for PDO #1018

@gjdanis

Description

@gjdanis

PHP 7.2 added support for specifying different bind types for unicode and non-unicode string data: https://wiki.php.net/rfc/extended-string-types-for-pdo

This is a major improvement over the default (PDO::PARAM_STR) which binds strings as unicode data. In the past, the inability for PHP to handle this has led to performance problems in certain cases. For example:

$statement = $pdo->prepare(
   'SELECT * FROM myTable WHERE myVarcharColumn = :value' -- will bind as N'...'
);

$statement->bindValue(':value', $myVarcharValue);
$statement->execute();

If there's an index on myVarcharColumn SQL won't be able to use the index effectively. More on this problem can be found here: http://blog.sqlgrease.com/are-varchar-or-char-hurting-your-performance-due-to-implicit-conversions/

Does the team have a plan to support this binding in the future?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions