PDO has no way to say "this value is binary." You bind it as a string with PDO::PARAM_STR or as a LOB with PDO::PARAM_LOB, and each driver does something different with it. Calvin Buckley's RFC adds PDO::PARAM_BINARY so you can state that a value is binary and every driver handles it the same way.
The RFC gives a few examples of where it goes wrong today:
- SQL Server, through
PDO_DBLIB, needs special quoting to escape binary data correctly, which you can't do from userland. - ODBC maps
PDO::PARAM_STRto a character type, so some drivers hand back a binary column as a hex-escaped string. - A binary column isn't a LOB either. Some drivers, like Postgres, expect a
PDO::PARAM_LOBvalue to be a stream resource.
How it works
Here is the RFC's example, reading a binary column over ODBC with the new type:
$dbconn = new PDO("odbc:*LOCAL", "", ""); $stmt = $dbconn->prepare("select id, my_blob from calvin.blob_stream"); $stmt->execute(); $data = ""; $stmt->bindColumn(2, $data, PDO::PARAM_BINARY); $stmt->fetch(PDO::FETCH_BOUND); echo bin2hex($data) . "\n";
The RFC leaves one design question open and describes two ways to build it:
- A dedicated data type.
PDO::PARAM_BINARYtakes the next free slot in PDO's type list. The RFC says this is simpler for drivers and matches how most databases treat binary as its own type. - A modifier flag.
PDO::PARAM_BINARYgets combined with an existing type, likePDO::PARAM_STR | PDO::PARAM_BINARY, the same way some drivers already handle "national" strings. The flag also works with LOBs, so you could mark a BLOB apart from a CLOB. The RFC notes it would have to work withPDO::ATTR_DEFAULT_STR_PARAM, which may complicate things.
If internals can't settle on one, the RFC puts both to a second vote.
What it means for existing code
Your current code keeps working. Drivers that don't tell binary and text strings apart can treat the new type as a regular string. The one visible change is that drivers may start reporting the binary type for binary and blob columns in getColumnMeta(). The RFC also mentions cleaning up how drivers use PDO::PARAM_LOB for binary data, but it might leave that for a later RFC.
Libraries that wrap PDO, like ORMs, would need to add support to use it.
Where it stands
This is a draft. Calvin Buckley created it on September 29, 2026, and it hasn't been announced on internals yet. It doesn't name a target version beyond the next PHP 8.x release. A proof of concept is up in php-src PR #11674, and it grew out of issue #11462.