Description
Feature Request
Q | A |
---|---|
New Feature | yes |
RFC | yes |
BC Break | no |
Summary
Currently it is driver dependent which parametrization is supported in prepared statements per driver when calling prepare()
on the connection object. I would suggest adding the parsing already present when calling either executeUpdate()
or executeSelect()
to prepare as well. This would have the following advantages in my opinion:
- It would make the supported drivers transparent to the user.
- The parsing of SQL could be moved to the driver implementation, and there would be no need to parse all statements as it is the case currently with the methods supporting both.
- Keeping BC
A possible disadvantage could be the overhead, however, this could be avoided for the most part by designing the API in a way that could side step any potential downside. For example, it would be possible to add an optional argument to prepare
, let's say, $statementType
which could default to native
which would keep the current behaviour and would not introduce parsing. On the other hand, users could specify named
or positional
for that additional argument, and if the driver doesn't support it, it could parse and replace the correct placeholders, if the driver doesn't support both.
All in all, this would add only an extra branch as overhead to users who do not care for this feature, while allowing users, who do not know which driver they will use at runtime to specify what they do expect from the DBAL to do. In my opinion, that is as close to a win-win as anyone can reasonably expect to get when using any abstraction layer.
Alternatively, I would suggest placing the note stating this difference between driver in a more prominent place in the docs.