|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-04-10 22:40 UTC] jax at student dot unibe dot ch
[2006-04-12 14:58 UTC] sniper@php.net
[2006-05-10 13:46 UTC] georg@php.net
[2006-05-27 01:13 UTC] helly@php.net
[2006-05-29 16:57 UTC] mike@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
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