note 95328 added to pdostatement.bindvalue
| From: | goofiq dot no dot spam at rd dot wp dot pl | Date: | Sun, 27 Dec 2009 18:43:39 +0000 |
| Subject: | note 95328 added to pdostatement.bindvalue | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164355@lists.php.net to get a copy of this message | ||
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 ();
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 94.75.74.26
----
Manual Page -- http://www.php.net/manual/en/pdostatement.bindvalue.php
Edit -- https://master.php.net/note/edit/95328
Del: integrated -- https://master.php.net/note/delete/95328/integrated
Del: useless -- https://master.php.net/note/delete/95328/useless
Del: bad code -- https://master.php.net/note/delete/95328/bad+code
Del: spam -- https://master.php.net/note/delete/95328/spam
Del: non-english -- https://master.php.net/note/delete/95328/non-english
Del: in docs -- https://master.php.net/note/delete/95328/in+docs
Del: other reasons-- https://master.php.net/note/delete/95328
Reject -- https://master.php.net/note/reject/95328
Search -- https://master.php.net/manage/user-notes.php