note 100131 deleted from pdo.quote by salathe

From: Date: Mon, 08 Jul 2013 09:52:03 +0000
Subject: note 100131 deleted from pdo.quote by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-195498@lists.php.net to get a copy of this message
Note Submitter: hungry dot rahly at gmail dot com ---- For those of you who do want to have null returned as NULL, it is fairly easy to add. <?php 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.

« previous php.notes (#195498) next »