Edit report at http://bugs.php.net/bug.php?id=51493&edit=1
ID: 51493
User updated by: zhuzhixiong at hotmail dot com
Reported by: zhuzhixiong at hotmail dot com
Summary: $result->num_rows return wrong
-Status: Open
+Status: Closed
Type: Bug
Package: MySQLi related
Operating System: window xp sp2
PHP Version: 5.2.13
New Comment:
Sorry for this.
It is my fault.
Previous Comments:
------------------------------------------------------------------------
[2010-04-07 11:06:30] zhuzhixiong at hotmail dot com
Description:
------------
mysql version is 5.1.45-community
when I use the script below,$result->num_rows return 0;(it is supported
to return 1;I echo the sql,and execute it in mysql client,and return 1
result)
if I change sql to "select `id` from mobile_breed",$result->num_rows
return the right numbers
Test script:
---------------
<?php
function getBreedId($breed_name,$handle)
{
$handle = new mysqli("localhost","root","123456","wjtx");
$sql = "select `id` from mobile_breed where
`breed_name`='".$breed_name."' limit 0,1";
$result = $handle->query($sql);
if(!$result)
{
return false;
}
else
{
$num = $result->num_rows();
if($num==0)
{
return false;
}
else
{
$row = $result->fetch_assoc();
return $row['id'];
}
}
}
echo getBreedId("nokia",'5230');
?>
Expected result:
----------------
return an id;
Actual result:
--------------
return false;
because $result->num_rows return 0,so returned fasle;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51493&edit=1