Edit report at http://bugs.php.net/bug.php?id=54551&edit=1
ID: 54551 Updated by: [email protected] Reported by: php_nospam at ramihyn dot sytes dot net Summary: pdo_mysql_stmt_get_col() converts DB integer to string -Status: Open +Status: Bogus Type: Bug Package: MySQL related Operating System: Any PHP Version: Irrelevant Block user comment: N Private report: N New Comment: . Previous Comments: ------------------------------------------------------------------------ [2011-04-17 20:36:11] [email protected] The issue actually is that PDO by default uses emulation of prepared statements. Only native prepared statements use the binary protocol which keeps the proper types. ------------------------------------------------------------------------ [2011-04-17 19:22:21] php_nospam at ramihyn dot sytes dot net Description: ------------ pdo_mysql_stmt_get_col() returns a string instead of an integer obtained from the database. This happens with the pdo_mysql extension included in the PHP download section as well as on my Ubuntu box. Looking at mysql_statement.c from the pdo_mysql source shows, that it returns a ZVAL reference instead of a string when compiled with mysqlnd, so if i may ask: why isnt it the default to compile with mysqlnd? Test script: --------------- <?php $mysql = new PDO('mysql:host=localhost;dbname=test', 'root', ''); $mysql->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); var_dump($mysql->query('SELECT 42')->fetch(PDO::FETCH_NUM)); ?> Expected result: ---------------- array(1) { [0]=> int(42) } Actual result: -------------- array(1) { [0]=> string(2) "42" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54551&edit=1
