note 95327 deleted from pdostatement.bindvalue by danbrown
| From: | danbrown@php.net | Date: | Sun, 27 Dec 2009 20:05:53 +0000 |
| Subject: | note 95327 deleted from pdostatement.bindvalue by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164356@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
bindValue with data_type depend parameter name
<?php
$db = new PDO (...);
$db -> setAttribute (PDO::ATTR_STATEMENT_CLASS, array ('MY_PDOStatement ', array
($db)));
class MY_PDOStatement extends PDOStatement {
public function execute ($input = array ()) {
foreach ($input as $param => $value) {
if (preg_match ('/_id$/', $param))
$this -> bindValue ($param, $value, PDO::PARAM_INT);
else
$this -> bindValue ($param, $value, PDO::PARAM_STR);
}
return parent::execute ();
}
}
?>