note 91081 deleted from pdostatement.bindparam by danbrown
| From: | danbrown@php.net | Date: | Mon, 25 May 2009 22:13:52 +0000 |
| Subject: | note 91081 deleted from pdostatement.bindparam by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155991@lists.php.net to get a copy of this message | ||
Note Submitter: tkalfigo at gmail dot com
----
Careful with the syntax of your query:
$query="UPDATE table SET aCol=1 WHERE id=:id";
$stmt=$dbh->prepare($query);
$stmt->setFetchMode(PDO::FETCH_BOUND);
$stmt->bindParam(':id', $varWithId, PDO::PARAM_INT);
The call to bindParam will fail with SQLSTATE [HY093] which means "invalid parameter" i.e.
it doesn't find your bind parameter.
Solution is to put a space betwee the SQL's assignment = and the name of the bound param:
$query="UPDATE table SET aCol=1 WHERE id= :id";