#36949 [Opn->Fbk]: mysqli->fetch_object cripples mysqli object so that it can't be closed correctl
| From: | tony2001@php.net | Date: | Sun, 02 Apr 2006 14:00:01 +0000 |
| Subject: | #36949 [Opn->Fbk]: mysqli->fetch_object cripples mysqli object so that it can't be closed correctl | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-95214@lists.php.net to get a copy of this message | ||
ID: 36949
Updated by: tony2001@php.net
Reported By: jax at student dot unibe dot ch
-Status: Open
+Status: Feedback
Bug Type: MySQLi related
Operating System: Gentoo Linux
PHP Version: 5.1.2
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.1-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.1-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2006-04-02 15:14:56] jax at student dot unibe dot ch
Description:
------------
Test Case for mysqli->fetch_object bug
class A and class B contain the exact same code
Using mysqli->fetch_object causes warning when the destructor of B is
called (mysqli->close()):
Warning: mysqli::close() [function.close]: Couldn't fetch mysqli in
/home/path/to/php/test.php on line 56 (destructor of B)
If mysqli->fetch_assoc is used instead of fetch_object, it works fine.
Replace
$row = $result->fetch_object();
echo $row->my_time;
With
$row = $result->fetch_assoc();
echo $row['my_time'];
to test
something must be wrong with fetch_object
Reproduce code:
---------------
class A {
private $mysqli;
public function __construct() {
$this->mysqli = new mysqli("localhost", "u", "p",
"test");
$result = $this->mysqli->query("SELECT NOW() AS my_time");
// -------- Line Causing Problem ------
$row = $result->fetch_object();
echo $row->my_time."<br>";
$result->close();
}
public function __destruct() {
$this->mysqli->close();
}
}
class B {
private $mysqli;
public function __construct() {
$this->mysqli = new mysqli("localhost", "u", "p",
"test");
$result = $this->mysqli->query("SELECT NOW() AS my_time");
// -------- Line Causing Problem --------
$row = $result->fetch_object();
echo $row->my_time."<br>";
$result->close();
}
public function __destruct() {
$this->mysqli->close();
}
}
$A = new A();
$B = new B();
Expected result:
----------------
$this->mysqli->close() should work without throwing an error
Actual result:
--------------
2006-04-02 15:01:36
2006-04-02 15:01:36
Warning: mysqli::close() [function.close]: Couldn't fetch mysqli in
/home/path/to/test.php on line 56
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36949&edit=1