Bug #67441 [Opn->Nab]: mysqli_result::fetch_array() returns an array with all values in string type.

From: Date: Sat, 14 Jun 2014 12:55:54 +0000
Subject: Bug #67441 [Opn->Nab]: mysqli_result::fetch_array() returns an array with all values in string type.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186191@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67441&edit=1 ID: 67441 Updated by: johannes@php.net Reported by: taopy at qq dot com Summary: mysqli_result::fetch_array() returns an array with all values in string type. -Status: Open +Status: Not a bug Type: Bug Package: MySQLi related Operating System: FreeBSD/CentOS PHP Version: 5.5.13 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php MySQL's network protocol is string based. We won't convert it but let PHP's type system handle this when needed. (MySQL prepared statements would use a sightly different protocol thus when doing prepare/execute you'd get an integer ...) Previous Comments: ------------------------------------------------------------------------ [2014-06-14 04:49:44] taopy at qq dot com Description: ------------ CREATE TABLE table_name ( id int not null primary key ); Obviously, field id is an integer. But whatever your field's type is, mysqli extension returns you string type. P.S.: I tried sqlite3 extension, no such a problem, it returns int value. Test script: --------------- $db = new \mysqli('host', 'user', 'pass', 'dbname'); $res = $db->query('select * from table_name;'); $arr = $res->fetch_array(MYSQLI_ASSOC); var_dump($arr); $arr->free(); $db->close(); Expected result: ---------------- It should returns an array like: array(1) { ["id"]=> int(1) } Actual result: -------------- array(1) { ["id"]=> string(1) "1" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67441&edit=1

« previous php.bugs (#186191) next »