This is an old revision of the document!
PHP RFC: Extended String Types For PDO
- Version: 0.1
- Date: 2017-02-16
- Author: Adam Baratz email@example.com
- Status: Under Discussion
- First Published at: https://wiki.php.net/rfc/extended-string-types-for-pdo
When using emulated prepared statements -- the default behavior for pdo_mysql, the only one for pdo_dblib -- it's not possible to quote parameters using this format. By not doing this, queries become more expensive because of an implicit cast.
Three constants would be added to the pdo extension:
- PDO::PARAM_STR_UNICODE. A new type, to be applied as a bitwise-OR to
PDO::PARAM_STR. It would indicate that the value should be quoted with the N-prefix.
- PDO::ATTR_UNICODE_STRINGS. This bool driver attribute would indicate whether all
PDO::PARAM_STRvalues should be treated like
PDO::PARAM_STR | PDO::PARAM_STR_UNICODEby default.
- PDO::PARAM_STR_ASCII. A new type, to be applied as a bitwise-OR to
PDO::PARAM_STR. It would indicate that the value should be quoted without the N-prefix. This would be intended to be used as an exception for when the
PDO::ATTR_UNICODE_STRINGSattribute is set to true.
Backward Incompatible Changes
Since this functionality would be opt-in, existing code would continue to work as it does. The bitmasked values would be ignored by other drivers, or pdo_mysql toggling off prepared statement emulation, so the portability valued for PDO code would be preserved.
Impact To Existing Extensions
Drivers outside of php-src might have to be modified if they make assumptions about the structure of
enum pdo_param_type. They would have to be rebuilt since the
PDO_DRIVER_API macro would be updated.
Proposed PHP Version(s)
Next PHP 7.x.
Proposed Voting Choices
This project requires a 50%+1 majority.