#39643 [Bgs->Opn]: Integers selected from a MySQL-database are treated as strings
| From: | harmen_php_net at xtremesf dot nl | Date: | Mon, 27 Nov 2006 15:11:04 +0000 |
| Subject: | #39643 [Bgs->Opn]: Integers selected from a MySQL-database are treated as strings | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-105482@lists.php.net to get a copy of this message | ||
ID: 39643
User updated by: harmen_php_net at xtremesf dot nl
Reported By: harmen_php_net at xtremesf dot nl
-Status: Bogus
+Status: Open
Bug Type: MySQLi related
PHP Version: 5.2.0
New Comment:
I think this is a bug, because it is not listed on
http://nl3.php.net/manual/en/function.mysqli-fetch-array.php.
But, if this is not a bug, how do I solve the problem, i.e., how do I
get the value returned as the right data type (e.g. integers as
integers, not as strings)?
Previous Comments:
------------------------------------------------------------------------
[2006-11-27 14:57:24] derick@php.net
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
.
------------------------------------------------------------------------
[2006-11-27 14:51:53] harmen_php_net at xtremesf dot nl
Description:
------------
When executing the query below, I get the wrong result. Although the
database returns a integer, PHP treats it as a string.
Here the relevant part of phpinfo():
MysqlI Support enabled
Client API library version 5.0.27
Client API header version 5.0.27
MYSQLI_SOCKET /tmp/mysql.sock
The version of the MySQL server is 5.0.27
Reproduce code:
---------------
<pre>
<?php
$rDB = mysqli_connect('localhost', 'user', 'password',
'db');
mysqli_select_db($rDB, 'db');
$rResult = mysqli_query($rDB, 'SELECT id FROM producten WHERE id =
4472');
var_dump(mysqli_fetch_array($rResult));
echo "\n---\n";
var_dump(mysqli_fetch_field($rResult));
?>
</pre>
Expected result:
----------------
array(2) {
[0]=>
int(4) "4472"
["id"]=>
int(4) "4472"
}
---
object(stdClass)#3 (11) {
["name"]=>
string(2) "id"
["orgname"]=>
string(2) "id"
["table"]=>
string(9) "producten"
["orgtable"]=>
string(9) "producten"
["def"]=>
string(0) ""
["max_length"]=>
int(4)
["length"]=>
int(11)
["charsetnr"]=>
int(63)
["flags"]=>
int(49699)
["type"]=>
int(3)
["decimals"]=>
int(0)
}
Actual result:
--------------
array(2) {
[0]=>
string(4) "4472"
["id"]=>
string(4) "4472"
}
---
object(stdClass)#3 (11) {
["name"]=>
string(2) "id"
["orgname"]=>
string(2) "id"
["table"]=>
string(9) "producten"
["orgtable"]=>
string(9) "producten"
["def"]=>
string(0) ""
["max_length"]=>
int(4)
["length"]=>
int(11)
["charsetnr"]=>
int(63)
["flags"]=>
int(49699)
["type"]=>
int(3)
["decimals"]=>
int(0)
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39643&edit=1