-
-
Notifications
You must be signed in to change notification settings - Fork 23
Prototype support for bindValue/bindParam on PDOStatement #265
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,10 @@ public function mixedParam(PDO $pdo, $mixed) | |
| $query = 'SELECT email FROM ada WHERE gesperrt=:gesperrt'; | ||
| $stmt = $pdo->prepare($query); | ||
| $stmt->execute([':gesperrt' => $mixed]); | ||
|
|
||
| $stmt = $pdo->prepare($query); | ||
| $stmt->bindValue(':gesperrt', $mixed); | ||
| $stmt->execute(); | ||
| } | ||
|
|
||
| public function noErrorOnMixedQuery(PDO $pdo, $mixed) | ||
|
|
@@ -38,5 +42,9 @@ public function noErrorOnStringValue(PDO $pdo, string $string) | |
| $query = 'SELECT adaid FROM ada WHERE email=:email'; | ||
| $stmt = $pdo->prepare($query); | ||
| $stmt->execute([':email' => '%|'.$string.'|%']); | ||
|
|
||
| $stmt = $pdo->prepare($query); | ||
| $stmt->bindValue(':email', '%|'.$string.'|%'); | ||
| $stmt->execute(); | ||
|
Comment on lines
+46
to
+48
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can/should cover a case where some params are bound via
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked at the pdo code, and it seemed like if you pass into execute, it empties any of the previously bound variables. I may have misunderstood though.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be cool if you could run a small example on your own and verify the thesis. if its right, we might even create a PHPStan-Rule which errors on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it's the case: $st = Container::Database()->prepare( 'SELECT * FROM Apps WHERE AppID = :a OR AppID = :b' );
$st->bindValue( ':a', 123 );
$st->execute( [ ':b' => 456 ] ); // SQLSTATE[HY093]: Invalid parameter number
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, thx |
||
| } | ||
| } | ||
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.
do we need this check here, or could we just feed everything into
$parameterKeysandresolveParameterslater on would decide which types are supported and which not?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.
It's constrained by the constructor, so phpstan complained.