Bug #67441 [NEW]: mysqli_result::fetch_array() returns an array with all values in string type.
| From: | taopy at qq dot com | Date: | Sat, 14 Jun 2014 04:49:44 +0000 |
| Subject: | Bug #67441 [NEW]: mysqli_result::fetch_array() returns an array with all values in string type. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186189@lists.php.net to get a copy of this message | ||
From: taopy at qq dot com
Operating system: FreeBSD/CentOS
PHP version: 5.5.13
Package: MySQLi related
Bug Type: Bug
Bug description:mysqli_result::fetch_array() returns an array with all values in string type.
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 bug report at https://bugs.php.net/bug.php?id=67441&edit=1
--