Proposal: Binary type for PDO

php.internals

Calvin Buckley

3 years ago
Hi internals@, I’m linking to a GH issue I filed a file back about extending PDO. It's intending to address common issues with dealing with bindary data that I've seen users deal with. In particular, I’d appreciate feedback from people with PDO internals, and any other DBMS' features/limitations that could affect this. The issue on GitHub is here: https://github.com/php/php-src/issues/11462 I'd like to hear any oversights, and what could be done to take this further. I haven’t heard much other than some +1s on the issue itself. Regards, Calvin

Dan Ackroyd

3 years ago
On Fri, 7 Jul 2023 at 18:39, Calvin Buckley <calvin@cmpct.info> wrote:
> > I'd like to hear any oversights, and what could be done to take this > further.
I think someone needs to write some code and some tests, and see what happens. It's possible that PARAM_BINARY could be used across all of the PDO drivers that PHP ships with, and for each of them the behaviour with that option is sensible. It's also possible that the behaviour of binary parameters is bespoke to each of the drivers, and that it isn't possible to use PARAM_BINARY in a DB agnostic way. The most realistic way to find out which option is more real, is to write the code + tests....which would need to be done anyway, even assuming the best case scenario. cheers Dan Ack

Calvin Buckley

3 years ago
> On Jul 9, 2023, at 11:29 AM, Dan Ackroyd <Danack@basereality.com> wrote: > > On Fri, 7 Jul 2023 at 18:39, Calvin Buckley <calvin@cmpct.info> wrote: >> >> I'd like to hear any oversights, and what could be done to take this >> further. > > I think someone needs to write some code and some tests, and see what happens. > > It's possible that PARAM_BINARY could be used across all of the PDO > drivers that PHP ships with, and for each of them the behaviour with > that option is sensible. > > It's also possible that the behaviour of binary parameters is bespoke > to each of the drivers, and that it isn't possible to use PARAM_BINARY > in a DB agnostic way. > > The most realistic way to find out which option is more real, is to > write the code + tests....which would need to be done anyway, even > assuming the best case scenario.
I have a WIP PR here: https://github.com/php/php-src/pull/11674 I have not implemented MySQL/Postgres/OCI/Firebird support, but I have tests for ODBC, DBLIB, and SQLite. I think your suspicions about it being bespoke might be correct, although the exercise isn’t for naught. Even if a PARAM_BINARY isn’t realistic to implement, it still identifies and has some fixes for PDO_ODBC and PDO_DBLIB that could be used independently from any PARAM_BINARY support. Further review and me figuring out the other drivers could help here.