note 127730 added to pdostatement.bindparam
| From: | weronika dot nowak dot code at gmail dot com | Date: | Mon, 17 Oct 2022 10:55:49 +0000 |
| Subject: | note 127730 added to pdostatement.bindparam | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219681@lists.php.net to get a copy of this message | ||
ð§¨ð§¨ð§¨
<?php
$q = "SELECT id, name FROM test WHERE name like '%:foo%'";
$s = "carrot";
$sth = $dbh->prepare($q);
$sth->bindParam(':foo', $s);
$sth->execute();
?>
It's true, this ⬠won't work but you can use concatenation â¬:
<?php
$q = "SELECT id, name FROM test WHERE name like '%' ||
:foo || '%' ";
$s = "carrot";
$sth = $dbh->prepare($q);
$sth->bindParam(':foo', $s);
$sth->execute();
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.159.161 (proxied: 164.40.241.163)
----
Manual Page -- https://php.net/manual/en/pdostatement.bindparam.php
Edit -- https://main.php.net/note/edit/127730
Del: integrated -- https://main.php.net/note/delete/127730/integrated
Del: useless -- https://main.php.net/note/delete/127730/useless
Del: bad code -- https://main.php.net/note/delete/127730/bad+code
Del: spam -- https://main.php.net/note/delete/127730/spam
Del: non-english -- https://main.php.net/note/delete/127730/non-english
Del: in docs -- https://main.php.net/note/delete/127730/in+docs
Del: other reasons-- https://main.php.net/note/delete/127730
Reject -- https://main.php.net/note/reject/127730
Search -- https://main.php.net/manage/user-notes.php