PDO binary parameter support proposal
Under discussion; not accepted. The RFC page (version 0.4, dated 2026-09-29, last modified 2026-10-16 at 19:47 UTC) and the official RFC index both list it as Under Discussion. Until 16 October both had listed it as Draft. The author opened the discussion on 2026-10-16 at 19:34 UTC. They asked for feedback in particular on MySQL and PostgreSQL behavior, and on whether the RFC should use a new data type or a flag. They said they want those points settled before a vote. The voting thread reads "tbd", and no vote has been scheduled. The proposed version is "Next PHP 8.x", so no specific version is named.
Proposal
The motivation is that PDO drivers handle binary data inconsistently: SQL Server via PDO_DBLIB
needs special quoting, some ODBC drivers return a binary column bound as a string as hex, and
some databases convert character encodings on string fetches. A binary column is not
necessarily a LOB, and some drivers expect PDO::PARAM_LOB to be a stream.
The RFC offers two alternatives: a dedicated PDO::PARAM_BINARY data type (the next free value,
6), or a modifier flag (likely 0x10000000) combined with PDO::PARAM_STR or PDO::PARAM_LOB.
It says the choice will be settled in discussion or, if that is unclear, by a vote. It notes possible effects on emulated prepares,
PDO::ATTR_DEFAULT_STR_PARAM, PDO::ATTR_STRINGIFY_FETCHES and on what drivers report from
getColumnMeta(). A proof-of-concept is php-src PR #11674.
The page has a primary vote that needs a 2/3 majority and a second vote on the approach (separate data type or flag). Both polls show zero votes and are marked closed. A reviewer points out that they still carry a 2026-01-01 close date. They are templates, not ballots.
Discussion
On 2026-10-16 at 20:43 UTC Ilia Alshanetsky posted a six-point review based on the current driver code:
PARAM_LOBwith a string is already binary in pdo_pgsql and pdo_sqlite, in pdo_mysql only when emulating prepares, and in pdo_odbc only whenSQLDescribeParam()fails. They asked whatPARAM_BINARYadds per driver.- A fallback to
PARAM_STRcorrupts data: pdo_pgsql truncates text-format parameters at the first NUL byte, and pdo_mysql loses the_binaryintroducer. They suggested a per-driver table covering native binding, emulated quoting and fetching. - Neither representation degrades safely. An unknown type 6 is treated as text in the bundled drivers and pdo_oci,
gives IM001 in pdo_ibm and a fatal error in pdo_sqlsrv. A flag survives only where code masks the type with
PDO_PARAM_TYPE(). They asked the RFC to require core to mask it, and to define whatPARAM_INT | PARAM_BINARYdoes (they suggested aValueError). - The ODBC hex problem is a driver bug that choosing
SQL_C_BINARYby column type would fix without a new constant. Raw fetches of character columns (EBCDIC/UTF-16) are the new capability. - Changing the
pdo_typereported bygetColumnMeta()breaks strict comparisons either way, and a separate key would avoid that. - Nits:
PDO::PARAM_STRINGshould bePDO::PARAM_STR, and the proof-of-concept dblib quoter checks the type exactly, so any added flag would skip it.
This review is the account of one participant and has not been checked against driver source code here.
The author replied at 22:27 UTC the same day. They said they would answer some points then and research the rest over the next week:
PARAM_LOBinconsistencies were an open issue that they now think must be addressed first, and they will try to add a per-driver table.PARAM_LOBmight cover most binary-string cases, but they find that confusingly named and harder for niche cases. They would accept making drivers treatPARAM_LOBconsistently for binary strings if participants prefer that.- For emulated prepares, checking string contents to pick binary quoting would be possible but slow and driver-specific.
- They consider marking the change as a breaking change for drivers reasonable.
- pdo_odbc binds result columns as
SQL_C_BINARYonly whenis_unicodeis set (Windows-specific), while parameters are bound as binary for binary columns but not blob columns. They said that could be improved independently of the RFC. - They expect a backward-compatibility break for code relying on
getColumnMeta()with any strategy, and mentioned a separate key like pdo_sqlite'sblobkey as a way to avoid it.
The data type or flag choice remains open. As of 2026-10-17 04:01 UTC no newer RFC page revision had been collected.
Limitations: no target version is named, and the proof-of-concept PR was not reviewed. Related: 16 October 2026 digest, support windows.