-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supporting both named and positional params in prepared stements in all drivers #4480
Comments
Both named and positional parameters are supported at the wrapper level. The driver level only supports the parameters supported by the underlying driver. Please see the details in #3891. |
This resonates with to #3744. |
My argument relating to this is that I would have assumed that Either way, I understand that my use case is probably not the most common one, so feel free to close this if you don't see any value in adding this functionality. |
It doesn't sound right. Any driver-level connection can prepare a statement that can be reused multiple times.
This is already supported.
I'm looking at the named/positional parameter support at the driver level from a totally different perspective. The current approach has certain downsides:
If the driver level declared explicit APIs for numeric and positional prepared statements, then the above issues wouldn't exist. |
Feature Request
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 eitherexecuteUpdate()
orexecuteSelect()
to prepare as well. This would have the following advantages in my opinion: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 tonative
which would keep the current behaviour and would not introduce parsing. On the other hand, users could specifynamed
orpositional
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.
The text was updated successfully, but these errors were encountered: