Issues

ZF-4773: Pass socket parameter into Mysqli constructor

Issue Type: New Feature Created: 2008-11-01T23:57:06.000+0000 Last Updated: 2013-01-18T08:18:21.000+0000 Status: Resolved Fix version(s): - 1.12.2 (25/Feb/13)

Reporter: Brian Caughlin (briancaughlin) Assignee: Marc Hodgins (mjh_ca) Tags: - Zend_Db_Adapter_Mysqli

Related issues: - ZF-1914

Attachments: - ZF-4773.new.patch

Description

The Pdo_Mysql adapter accepts a "unix_socket" parameter in its options array, but the plain Mysqli Adapter doesn't. Case ZF-1914 suggests that this isn't needed because you can set it in php.ini, but there are still some cases where it's nice to pass it in on the fly. In either case, this should be simple to add.

After line 299 in library/Zend/Db/Adapter/Mysqli.php:

<pre class="highlight">
        if (isset($this->_config['unix_socket'])) {
            $socket = $this->_config['unix_socket'];
        } else {
            $socket = null;
        }

And then continuing and replacing starting at existing line 300:

<pre class="highlight">
        // Suppress connection warnings here.
        // Throw an exception instead.
        @$this->_connection = new mysqli(
            $this->_config['host'],
            $this->_config['username'],
            $this->_config['password'],
            $this->_config['dbname'],
            $port,
            $socket
        );

(Existing line 309 would follow... It seems to be munching the spaces on the first respective lines as well.)

I tried this on my local installation, and it seems to work both in cases where you do and don't use sockets.

Comments

Posted by Mark Evans (sparky) on 2008-12-19T10:20:17.000+0000

Added a patch against latest trunk

Posted by Shaddy Zeineddine (shaddyz) on 2010-11-24T20:34:39.000+0000

can someone close this issue since it duplicates another issue which has been resolved?

Posted by Marc Hodgins (mjh_ca) on 2010-11-24T21:32:44.000+0000

See resolution in ZF-1914

Posted by Brian Caughlin (briancaughlin) on 2010-11-24T21:46:36.000+0000

Well, this issue is actually not resolved in ZF-1914, as I mentioned in the original report. ZF-1914 suggests that you should set the socket in the php.ini file, but that doesn't allow you to use different sockets on a per-connection basis. If you use PDO now, it will work, but not with mysqli. The one line added suggested in the original report would fix the issue, though; in 1.11 that line still isn't there.

Maybe resolve as "Not an issue" if you choose, but it isn't a duplicate. ZF-5053 is a duplicate of this, though.

Posted by Marc Hodgins (mjh_ca) on 2010-11-24T21:56:21.000+0000

@Brian: Ah, you're right. Apologies. Reopening & will look into writing a test case and getting this applied.

Posted by Marc Hodgins (mjh_ca) on 2010-11-25T01:03:29.000+0000

Attaching patch that also updates documentation for mysqli adapter.

Posted by Shaddy Zeineddine (shaddyz) on 2010-11-25T02:06:15.000+0000

I was wondering why I have still been using my own connect method. Thanks for the quick response and moving to get this issue resolved!

Posted by Frank Br├╝ckner (frosch) on 2013-01-18T08:18:21.000+0000

Fixed on trunk (25228) and release-1.12 (25229)

Thanks to Marc!

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts