note 89548 deleted from pdostatement.bindparam by danbrown
| From: | danbrown@php.net | Date: | Fri, 13 Mar 2009 14:38:50 +0000 |
| Subject: | note 89548 deleted from pdostatement.bindparam by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151834@lists.php.net to get a copy of this message | ||
Note Submitter: ankit dot limkar at rediffmail dot com
----
Following code does not work having configuration php 5.2.3,apache 2.2.4 & mysql 5.0.45 on
Windows XP Professional:
<?php
function findByAll($code=null,$name=null,$quantity=null) {
$sql = "select * from product where 1=1 ";
if(isset($code)){
$sql = $sql . " and code=:code ";
}
if(isset($name)){
$sql = $sql . " and name like '%'||:name||'%' ";
}
if(isset($quantity)){
$sql = $sql . " and quantity=:quantity ";
}
$statement=$this->conn->prepare($sql);
if(isset($code)){
$statement->bindParam(':code',$code);
}
if(isset($name)){
$statement->bindParam(':name',$name);
}
if(isset($quantity)){
$statement->bindParam(':quantity',$quantity);
}
$statement->execute();
$rows=$statement->fetchAll();
$productVoList=&$this->getFromResults($rows);
return $productVoList;
}
?>
though correct records are present in database & $name contains the right value the query
generated looks like:
select * from product where 1=1 and name like '%'||:name||'%'.
hence parameter is not bound. PDO::bindParam() also returns true.