note 89548 added to pdostatement.bindparam

From: Date: Fri, 13 Mar 2009 05:48:06 +0000
Subject: note 89548 added to pdostatement.bindparam
Groups: php.notes 
Request: Send a blank email to php-notes+get-151817@lists.php.net to get a copy of this message
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. ---- Server IP: 59.162.86.33 Probable Submitter: 122.169.8.99 ---- Manual Page -- http://www.php.net/manual/en/pdostatement.bindparam.php Edit -- https://master.php.net/note/edit/89548 Del: integrated -- https://master.php.net/note/delete/89548/integrated Del: useless -- https://master.php.net/note/delete/89548/useless Del: bad code -- https://master.php.net/note/delete/89548/bad+code Del: spam -- https://master.php.net/note/delete/89548/spam Del: non-english -- https://master.php.net/note/delete/89548/non-english Del: in docs -- https://master.php.net/note/delete/89548/in+docs Del: other reasons-- https://master.php.net/note/delete/89548 Reject -- https://master.php.net/note/reject/89548 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151817) next »