Edit report at https://bugs.php.net/bug.php?id=63958&edit=1
ID: 63958 Updated by: [email protected] Reported by: r dot schneider at artworx dot at Summary: Fetch provides only strings with MySQL -Status: Open +Status: Feedback Type: Feature/Change Request Package: PDO related PHP Version: Irrelevant Block user comment: N Private report: N New Comment: How does this make "the proper usage of fetchObject('myClass') not possible"? The reason is that the MySQL Server sends strings to PHP. PHP doesn't touch it further. If you use native prepared statments (PDO uses an emulation by default) MySQL switches to a different protocol and you get more native types (while even that doesn't cover all types properly - thing MySQL DECIMAL, there is no precise numeric type in PHP for non-integers) Previous Comments: ------------------------------------------------------------------------ [2013-01-10 10:38:06] r dot schneider at artworx dot at Description: ------------ --- >From manual page: http://www.php.net/pdostatement.fetch --- With MySQL all those fetch methods provide only strings. All integers in the table have to be converted manually. This should be noted somewhere. I didn't know this for long time and I didn't have any problem with this because of the implicit conversioning in php. I detected it just recently. I don't understand why PDO behaves like this. This makes the proper usage of fetchObject('myClass') not possible. Maybe I have a wrong understanding of how to use php with its implicit conversions. Should I avoid distinguishing between data types, should all primitive data type operations work also with strings? At least I would expect that the documentation clearly states this fact. But better would be if the correct data types gets used. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63958&edit=1
