ID:               28765
 User updated by:  chall5 at tampabay dot rr dot com
-Reported By:      chall5 at tamapbay dot rr dot com
+Reported By:      chall5 at tampabay dot rr dot com
 Status:           Open
 Bug Type:         Class/Object related
 Operating System: linux fedora core 2
 PHP Version:      5.0.0RC3
 New Comment:

correcting my email address


Previous Comments:
------------------------------------------------------------------------

[2004-06-14 02:52:29] chall5 at tamapbay dot rr dot com

and yes, i know i left my root mysql password in the code.  its on a
non-networked dev box, so it doesn't matter.

------------------------------------------------------------------------

[2004-06-14 02:49:09] chall5 at tampabay dot rr dot com

Description:
------------
using get_object_vars() on a mysqli object returns an empty array.  As
I am able to access vars such as host_info via $mysqliObj->host_info, i
would expect this to be a public var, which I would expect to be
returned from get_object_vars($mysqliObj).  to test this, i defined a
test class with a public var, a private var, and a protected var. 
after instatiating the class an setting each of the vars to a string
value, i called get_object_vars() on the object and as expected, only
the public var was returned in the array from the function.

I also tested get_class_methods() and get_class_vars() on the mysqli
object.  get_class_methods() does return an array of method names. 
get_class_vars() returns an empty array.  these tests are NOT included
in the attached code.

Reproduce code:
---------------
<?php
class testClass {
        public $a;
        private $b;
        protected $c;
        public function test() {
                $this->a = "a";
                $this->b = "b";
                $this->c = "c";
        }
}

$mysqli = new mysqli("localhost", "root", "vnbeRTC", "mysql");
echo "mysqli class:\n";
echo "host info: ".$mysqli->host_info."\n\n";  // direct access, public
var???
echo "get_object_vars(\$mysqli)\n";
print_r(get_object_vars($mysqli)); // prints empty array
$mysqli->close();
echo "\ntestClass class:\n";
$test = new testClass;
$test->test();
echo "get_object_vars(\$test)\n";
print_r(get_object_vars($test)); // prints public vars only (expected)
print_r(get_class_vars($test)); // strange output for protected var
name
?>

Expected result:
----------------
array returned from get_object_vars() on a mysqli object would return
an array containing all public vars in the object.

Actual result:
--------------
the returned array was empty.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28765&edit=1

Reply via email to