php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33263 parent::real_connect() can not be used, hence cant use option flags.
Submitted: 2005-06-07 14:08 UTC Modified: 2005-11-25 16:39 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: daarius at hotmail dot com Assigned: georg (profile)
Status: Not a bug Package: MySQLi related
PHP Version: 5.1 OS: WinXP
Private report: No CVE-ID: None
 [2005-06-07 14:08 UTC] daarius at hotmail dot com
Description:
------------
class mydb extends mysqli {
   public function __construct() {
      parent::real_connect(); // can not use
      parent::__construct(); // doesnt support 7th parameter of flags.
   }
}

as above, the real_connect() gives some errors, and may be not allowed to be used, but in there the 7th parameter of flags are not present in connect() of mysqli. so what to do?

also, as real_connect() is not allowed, i can not use parent::options() for setting the config options before connect. as this gives errors too.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-08 00:25 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-06-08 18:30 UTC] daarius at hotmail dot com
I have used latest win32 version, and the problem is same. is there any other way of doing this in the new version?
 [2005-06-17 18:37 UTC] georg@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2005-11-25 12:20 UTC] daarius at hotmail dot com
just tried on new version php5.1, and the error is same. using parent::real_connect() in the constructor of my class that extends mysqli doesnt work and gives error of "warning: mysqli::real_connect() [function.real-connect]: Couldn't fetch"

need to use real_connect as it has the 7th param of flags, which is not present in parent::__construct() (mysqli_connect)

please check,
thanks.
 [2005-11-25 12:47 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2005-11-25 16:10 UTC] daarius at hotmail dot com
Following code works, but not usefull if you want to use the "flags" for the connection which is not availabe in __construct() which i believe is a call to mysqli_connect()

/**
 * Works ok, but without the option of flags
 */
class MyDb extends mysqli {
   public function __construct() {
      parent::__construct(
         'localhost', 'root', NULL, 'test', 3306, NULL
      );
   }
}
$o = new MyDb();

But, the real_connect() has the 7th option for "flags", but upon usage it gives the error:

/**
 * This is needed, but does not work
 */
class MyDb extends mysqli {
   public function __construct() {
      parent::real_connect(
         'localhost', 'root', NULL, 'test', 3306, NULL, 0
      );
   }
}
$o = new MyDb();

Error:
Warning: mysqli::real_connect() [function.real-connect]: Couldn't fetch MyDb in C:\httpd\index.php on line 7
 [2005-11-25 16:39 UTC] tony2001@php.net
Add parent::init(); before parent::real_connect() and it works.
"mysqli_real_connect() needs a valid object which has to be created by function mysqli_init()" (c) http://php.net/mysqli_real_connect
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC