Option 'persistent' in config of database

infis

Well-known member
Why the option $config [' db] [' persistent '] is not used?
Any problems are connected with it or have simply forgotten it to add in a code?

Version 1.0.4 library/Xenforo/Application.php
PHP:
    public function loadDb(Zend_Config $dbConfig)
    {
        $db = Zend_Db::factory($dbConfig->adapter,
            array(
                'host' => $dbConfig->host,
                'port' => $dbConfig->port,
                'username' => $dbConfig->username,
                'password' => $dbConfig->password,
                'dbname' => $dbConfig->dbname,
                'charset' => 'utf8'
            )
        );
Version 1.1.0 Beta 4 library/Xenforo/Application.php
PHP:
    public function loadDb(Zend_Config $dbConfig)
    {
        $db = Zend_Db::factory($dbConfig->adapter,
            array(
                'host' => $dbConfig->host,
                'port' => $dbConfig->port,
                'username' => $dbConfig->username,
                'password' => $dbConfig->password,
                'dbname' => $dbConfig->dbname,
                'adapterNamespace' => $dbConfig->adapterNamespace,
                'charset' => 'utf8'
            )
        );

Also what for an option adapterNamespace?
 
Sites with 5 to up to 100 users online on a shared hosting or better that support 100 persistent connections could perhaps use this. Everything above that or else doesn't want to use it.

I can not imagine a reason why anybody wants to use persistent connections. MySQL is made to support quick connects/disconnects quickly enough, and most web applications don't use them because of the amount of traffic they're getting. It only creates overhead. The cons outweigh the pros in my opinion.

Plus, every Apache child proc will get a persistent connection, on a somewhat busy box (especially on shared hosting) you end up with overwhelming MySQL and running into errors.

I guess the one benefit of pc is that when you open the connection, and as long as it remains in scope, you can run multiple queries, in my opinion not something useful to a web app such as a forum.
 
Sites with 5 to up to 100 users online on a shared hosting or better that support 100 persistent connections could perhaps use this. Everything above that or else doesn't want to use it.
Why you consider only the shared hosting? Own servers are now quite popular VPS and VDS, and also.
I can not imagine a reason why anybody wants to use persistent connections. MySQL is made to support quick connects/disconnects quickly enough, and most web applications don't use them because of the amount of traffic they're getting. It only creates overhead. The cons outweigh the pros in my opinion.
MySQL on one server with a site and on different - not same. And in real life there are many hosters giving a site and the server of a database, located physically on different computers.
I think, what it is not necessary to explain, what such work through Unix sockets and through TCP?
Plus, every Apache child proc will get a persistent connection, on a somewhat busy box (especially on shared hosting) you end up with overwhelming MySQL and running into errors.

I guess the one benefit of pc is that when you open the connection, and as long as it remains in scope, you can run multiple queries, in my opinion not something useful to a web app such as a forum.
I have initially raised the question not about expediency, and about absence of possibility of use of persistent connections.
I.e. me interested more, whether it is connected with what that errors or it have simply forgotten to add a class code.

The expediency of use of this option, certainly, depends on concrete conditions. In most cases, by the way, this option allows to reduce time of generation of page. Probably, not in a case with xenForo.
 
Persistent connections aren't implemented like that in MySQLi: http://php.net/manual/en/mysqli.persistconns.php

Zend_Db doesn't actually use the persistent flag anyway. So you just need to adjust your host name if it's supported by your PHP (eg, p:localhost).
I use PHP 5.2 and flag "p:" is not working.
Code:
An exception occurred: Unknown MySQL server host 'p:localhost' (1) in /xxxxxxxx/library/Zend/Db/Adapter/Mysqli.php on line 333

    Zend_Db_Adapter_Mysqli->_connect() in Zend/Db/Adapter/Abstract.php at line 315
    Zend_Db_Adapter_Abstract->getConnection() in XenForo/Application.php at line 550
    XenForo_Application->loadDb()
    call_user_func_array() in XenForo/Application.php at line 777
    XenForo_Application->lazyLoad() in XenForo/Application.php at line 807
    XenForo_Application::get() in XenForo/Application.php at line 1056
    XenForo_Application::getDb() in XenForo/Error.php at line 47
    XenForo_Error::unexpectedException() in XenForo/Application.php at line 295
    XenForo_Application::handleException()
 
Why you consider only the shared hosting? Own servers are now quite popular VPS and VDS, and also.

MySQL on one server with a site and on different - not same. And in real life there are many hosters giving a site and the server of a database, located physically on different computers.
I think, what it is not necessary to explain, what such work through Unix sockets and through TCP?

I have initially raised the question not about expediency, and about absence of possibility of use of persistent connections.
I.e. me interested more, whether it is connected with what that errors or it have simply forgotten to add a class code.

The expediency of use of this option, certainly, depends on concrete conditions. In most cases, by the way, this option allows to reduce time of generation of page. Probably, not in a case with xenForo.

I actually advise everybody to NOT use shared hosting. So I completely agree with you
But used shared hosting as example where people run into persistent connection max reached, etc.
 
I use PHP 5.2 and flag "p:" is not working.
That's why I linked to that manual page:
Persistent connection support was introduced in PHP 5.3 for the mysqli extension.
I don't mean this in a condescending way, but if you're not running PHP 5.3 (with an opcode cache) then it's not really worth pursuing other micro-optimizations -- you will see bigger speedups from upgrading to 5.3 (and PHP 5.2 is deprecated now as well).
 
But used shared hosting as example where people run into persistent connection max reached, etc.
Yes, it is difficult to disagree with it.
I don't mean this in a condescending way, but if you're not running PHP 5.3 (with an opcode cache) then it's not really worth pursuing other micro-optimizations -- you will see bigger speedups from upgrading to 5.3 (and PHP 5.2 is deprecated now as well).
Unfortunately, not always it is possible to use that would be desirable. On the new server at me costs 5.3, and here on old - 5.2.
Well. It is not critical, and the thread can be closed.

It would be good, that the information on distinctions in version PHP and in work xenForo would be accessible at a stage of a choice of the forum engine. That is, it is necessary to inform on it in results of work of a script of check of conformity to requirements of the forum engine. There (in a script) it is necessary to add and check PHP extension imagick, by the way :)
 
Top Bottom