-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Mysqli bind in execute #6271
Merged
kamil-tekiela
merged 17 commits into
php:master
from
kamil-tekiela:mysqli-bind-in-execute
Apr 14, 2021
Merged
Mysqli bind in execute #6271
kamil-tekiela
merged 17 commits into
php:master
from
kamil-tekiela:mysqli-bind-in-execute
Apr 14, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kamil-tekiela
force-pushed
the
mysqli-bind-in-execute
branch
from
October 30, 2020 14:42
79a3778
to
1850f79
Compare
kamil-tekiela
force-pushed
the
mysqli-bind-in-execute
branch
from
December 18, 2020 15:09
1850f79
to
b159787
Compare
nikic
reviewed
Jan 5, 2021
nikic
reviewed
Jan 5, 2021
nikic
reviewed
Jan 6, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks basically good to me.
kamil-tekiela
force-pushed
the
mysqli-bind-in-execute
branch
from
January 6, 2021 13:54
002f56b
to
ea02a90
Compare
kamil-tekiela
force-pushed
the
mysqli-bind-in-execute
branch
from
February 11, 2021 20:36
ea02a90
to
e07f958
Compare
kamil-tekiela
force-pushed
the
mysqli-bind-in-execute
branch
from
February 28, 2021 17:38
e07f958
to
ac792d9
Compare
kocsismate
reviewed
Mar 12, 2021
Nice work @kamil-tekiela - good DX improvements :-) |
kamil-tekiela
force-pushed
the
mysqli-bind-in-execute
branch
from
March 28, 2021 13:21
ac792d9
to
8ca6548
Compare
nikic
reviewed
Apr 13, 2021
Co-authored-by: Nikita Popov <nikita.ppv@googlemail.com>
Co-authored-by: Nikita Popov <nikita.ppv@googlemail.com>
Co-authored-by: Nikita Popov <nikita.ppv@googlemail.com>
A new test case was added to check for the exception with libmysqlclient
This reverts commit 8ca6548.
kamil-tekiela
force-pushed
the
mysqli-bind-in-execute
branch
from
April 13, 2021 16:06
f697abd
to
46257dc
Compare
nikic
approved these changes
Apr 14, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Target Version: PHP 8.1
Introduction
PDO has always offered binding values to the prepared statement directly in the
execute()
call by providing an array with the values. The same functionality was never present in mysqli, but many users have been confused by that lack of seemingly easy functionality. (See Bug #40891, Bug #31096)Proposal
I would like to propose adding a new optional argument to
mysqli_stmt::execute()
same as PDO does withPDOStatement::execute()
. The goal of this proposal is to simplify mysqli usage with a simple fix which does not require major refactoring.This proposal tries to address the following mysqli limitations:
What about type specifications?
MySQL can type juggle as easily as PHP. The safest way to bind parameters if you are not 100% certain of their type is to bind as a string. In many cases, this is the preferred simplest way. Type specifications should only be used in rare situations when the data should be passed to MySQL with a specific type. In reality, such situations are extremely rare and they depend on the SQL not on PHP data type. For these rare cases, we can continue using
bind_param()
with the right type specification.Difference between PDO and mysqli
While the idea came from PDO bind-in-execute implementation, the mysqli proposal differs in two small ways.
libmysql support?
Unfortunately, I am limited to Windows programming and I have no way of developing the same for libmysql and testing it myself. In theory, it should be possible to add this for libmysql with slight adjustments, but support for libmysql is not actively maintained at the moment and there are more problems that would probably need to be addressed by whoever decides to maintain libmysql support.
Backward Incompatible Changes
None that I can find.