note 78173 rejected from function.PDOStatement-bindParam by ezyang

From: Date: Wed, 03 Oct 2007 01:23:15 +0000
Subject: note 78173 rejected from function.PDOStatement-bindParam by ezyang
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-131006@lists.php.net to get a copy of this message
Note Submitter: JJ Rock ---- Does anybody see anything wrong with using bindParam this way? BTW, it does work... // $query is our parameterized query // $params is an array of :param => value public function getResultWithParameters($query,$params) { $statement = $db->prepare($query); foreach ($params as $key=>$value) { $statement->bindParam($key,$value); } $statement->execute(); } I'm calling this class function from outside the class, so I just want to send the parameterized query and the parameters and let the function do the binding. I realize I lose some functionality, like being able to call the execute() method multiple time with different parameters just by changing the variables. Anybody have insight as to why I would not want to use this?

« previous php.notes (#131006) next »