note 100131 added to pdo.quote
| From: | hungry dot rahly at gmail dot com | Date: | Mon, 27 Sep 2010 16:31:08 +0000 |
| Subject: | note 100131 added to pdo.quote | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172738@lists.php.net to get a copy of this message | ||
For those of you who do want to have null returned as NULL, it is fairly easy to add.
class Real_PDO extends PDO {
public function quote($value, $parameter_type = PDO::PARAM_STR ) {
if( is_null($value) ) {
return "NULL";
}
return parent::quote($value, $parameter_type);
}
}
then all you have to do is change your creation of the PDO object to this new class, and you
shouldn't have to change any other function calls. The nice thing about this method is that
you can override any PDO function or add your own. IMO, PDO should natively handle this, as there
is a difference in databases between NULL and an empty string(''), the quoting of numeric
values is another issue altogether.
----
Server IP: 69.147.83.197
Probable Submitter: 173.161.150.137
----
Manual Page -- http://www.php.net/manual/en/pdo.quote.php
Edit -- https://master.php.net/note/edit/100131
Del: integrated -- https://master.php.net/note/delete/100131/integrated
Del: useless -- https://master.php.net/note/delete/100131/useless
Del: bad code -- https://master.php.net/note/delete/100131/bad+code
Del: spam -- https://master.php.net/note/delete/100131/spam
Del: non-english -- https://master.php.net/note/delete/100131/non-english
Del: in docs -- https://master.php.net/note/delete/100131/in+docs
Del: other reasons-- https://master.php.net/note/delete/100131
Reject -- https://master.php.net/note/reject/100131
Search -- https://master.php.net/manage/user-notes.php