ID:               33274
 User updated by:  flying dot mushroom at gmail dot com
-Reported By:      flying dot mushroom at gmail dot cp,
+Reported By:      flying dot mushroom at gmail dot com
 Status:           Open
 Bug Type:         MySQLi related
 Operating System: Linux
 PHP Version:      5.0.3
 New Comment:

Oops; mistyped my email. Should read flying dot mushroom at gmail dot
com


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

[2005-06-08 12:27:00] flying dot mushroom at gmail dot com

Description:
------------
A class that extends mysqli, if passing its own members directly to the
parent constructor, will have those members mangled after the call.

Assigning member values to local variables and then passing those to
the parent solves the problem on for the user, but the above behaviour
shouldn't happen...?

(Replacing the line "parent::__construct($this->p_host, $this->p_uname,
$this->p_password);" with "parent::__construct($host, $username,
$password);" produces the expected result.)

This same problem is reported on the comment by hans at lintoo dot dk
on http://www.php.net/manual/en/ref.mysqli.php

Reproduce code:
---------------
<?php

class db_mysql extends mysqli
{
    private $p_host;
    private $p_uname = '';
    private $p_password = '';

    public function __construct($host, $username = '', $password = '')
    {
        $this->p_host     = $host;
        $this->p_uname    = $username;
        $this->p_password = $password;

        parent::__construct($this->p_host, $this->p_uname,
$this->p_password);
    }
}

var_dump(new db_mysql('localhost', 'username', 'password'));
?>

Expected result:
----------------
object(db_mysql)#1 (3) {
  ["p_host:private"]=>
  string(9) "localhost"
  ["p_uname:private"]=>
  string(8) "username"
  ["p_password:private"]=>
  string(8) "password"
}

Actual result:
--------------
object(db_mysql)#1 (3) {
  ["p_host:private"]=>
  string(9) "localhost"
  ["p_uname:private"]=>
  string(8) "username"
  ["p_password:private"]=>
  NULL
}


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


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

Reply via email to