note 110216 deleted from pdo.setattribute by googleguy
| From: | googleguy@php.net | Date: | Wed, 03 Oct 2012 02:28:32 +0000 |
| Subject: | note 110216 deleted from pdo.setattribute by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191105@lists.php.net to get a copy of this message | ||
Note Submitter: vincent at lycoops dot be
----
This paramter does magic (at least for MySQL):
PDO::ATTR_EMULATE_PREPARES => false
I don't know why, but it allows you to get the real types of a column value.
When you don't use it, any type returned by PDO will be a string (or NULL), even if it's
been saved as an integer or float. Typecasting in PHP can be very painful and may slow down your
application a lot.
With ATTR_EMULATE_PREPARES set to FALSE, integers and floats (also doubles) are really ints and
floats in PHP.
For information:
- The datatype decimal still returns a string to keep the precision.
- As MySQL doesn't know the datatype Boolean, the expression 1 = 1 returns 1 and not TRUE.