ID:               43866
 Updated by:       dani...@php.net
 Reported By:      basilio dot vera at softonic dot com
 Status:           Bogus
 Bug Type:         MySQLi related
 Operating System: Linux RHEL4
 PHP Version:      5.2.5
 New Comment:

Examples added to manual.


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

[2008-01-17 18:35:52] u...@php.net

Not a bug, solution is given, documentation "flaw" discussed.

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

[2008-01-17 17:54:44] basilio dot vera at softonic dot com

For example with an example inside the mysqli_init() or
mysqli_options() function docs:

class mysqli2 extends mysqli
{
    public function __construct( $host, $user, $pass, $db )
    {
        parent::init();
        parent::options( MYSQLI_OPT_CONNECT_TIMEOUT, 5 );
        parent::real_connect( $host, $user, $pass, $db );
    }
}

Regards.

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

[2008-01-17 17:29:50] u...@php.net

Give me a hint, what's up with the documentation?

http://us2.php.net/mysqli_connect shows that calling constructor of the
mysqli class is equal to calling mysqli_connect(). As you know, you need
to call mysqli_options() before a connection has been established. In
your reproduceable code you suggest a derived class which explicitly
calls the parent constructor to create a connection. Once the parent
constructor has been called you try to call mysqli_options()
(mysqli::options()). That's too late.

Your second example gets it right. How could we improve the
documentation? Thanks!

Ulf

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

[2008-01-17 00:19:51] basilio dot vera at softonic dot com

Hi, I've found a solution for this problem. It can be solved with:

class mysqli2 extends mysqli
{
    public function __construct( $host, $user, $pass, $db )
    {
        $this->init();
        $this->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
        $this->real_connect( $host, $user, $pass, $db );
    }
}

But you may consider review your docs, because it's and undocumented
feature!

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

[2008-01-16 14:34:39] basilio dot vera at softonic dot com

Sorry, the error message was:

'Couldn't fetch mysqli2'

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/43866

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

Reply via email to