note 66716 added to function.pdostatement-bindvalue
| From: | ChrisL at osu1 dot php dot net | Date: | Fri, 26 May 2006 22:43:57 +0000 |
| Subject: | note 66716 added to function.pdostatement-bindvalue | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112345@lists.php.net to get a copy of this message | ||
I'm not sure if this is intentional or not, but you can't use a placeholder more than
once. I assumed (wrongly) that bindValue() would replace ALL instances of a given placeholder with a
value. For example:
<?php
// $db is a PDO object
$stmt = $db->prepare
('
insert into
TableA
(
ID,
Name,
Foo
)
select
null,
:Name,
:Foo
from
TableA
where
Foo = :Foo
');
$stmt->bindValue(':Name', 'john doe');
$stmt->bindValue(':Foo', 'foo');
$stmt->execute();
?>
This apparently won't work - you must have separate :SelectFoo and :WhereFoo. I'm using
PHP 5.0.4, MySQL 5.0.14, and PDO version 1.0.2.
----
Server IP: 64.71.164.2
Probable Submitter: 24.158.209.88
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.pdostatement-bindvalue.php
Edit -- http://master.php.net/note/edit/66716
Del: integrated -- http://master.php.net/note/delete/66716/integrated
Del: useless -- http://master.php.net/note/delete/66716/useless
Del: bad code -- http://master.php.net/note/delete/66716/bad+code
Del: spam -- http://master.php.net/note/delete/66716/spam
Del: non-english -- http://master.php.net/note/delete/66716/non-english
Del: in docs -- http://master.php.net/note/delete/66716/in+docs
Del: other reasons-- http://master.php.net/note/delete/66716
Reject -- http://master.php.net/note/reject/66716
Search -- http://master.php.net/manage/user-notes.php