PHP RFC: Driver-Specific PDO Param Types
- Version: 0.1
- Date: 2016-10-17
- Author: Adam Baratz firstname.lastname@example.org
- Status: Under Discussion
- First Published at: https://wiki.php.net/rfc/driver-specific-pdo-param-types
Databases used with PDO can have nuances that fall outside the types defined by PDO (the
PDO::PARAM_* consts). These nuances can't always be made transparent to the developer. A wider range of types would allow developers to create better queries. Much like PDO supports driver-specific attributes, it should also support driver-specific param types.
This issue is particularly exposed to pdo_dblib users. Since pdo_dblib relies on prepared statement emulation – DB-Library doesn't support prepared statements – developers must build queries as they should be executed by the server. There have been a couple issues logged related to this. The current workaround is to use CAST (or implicit casts) with the existing data types. Doing so adds cost to queries.
By adding a placeholder value to enum pdo_param_type, PDO drivers can add types as they see fit. The PR contains two examples of how this would be used with pdo_dblib.
Backward Incompatible Changes
No modifications are needed to the supported PDO drivers, but they would have to be rebuilt against this API change. Other drivers might have to be modified if they make assumptions about the structure of
Proposed PHP Version(s)
Next PHP 7.x.
The example code introduces the following constants:
Proposed Voting Choices
This project requires a 50%+1 majority.
Patches and Tests
Working implementation, with tests: https://github.com/php/php-src/pull/2168