Slow parent :: __ construct in mysqli extended class

I am extending mysqli in a database class. I noticed that calling the parent constructor takes almost 2 seconds. Perhaps I suppose this is my environment, as I develop my desktop before deployment. But this does not seem to me very likely.

Wednesday:

  • OS - Windows 7 Pro
  • WAMP server
  • Apache / 2.2.17 (Win32)
  • PHP 5.3.4
  • MySql ver 5.1.53
  • NetBeans IDE 6.9.1

The code in question:

class DGMysqliLink extends MySQLi
{
    public function __construct($aDSN)
    {
        // Construct the DSN
        $aDSN['dbhost'] = (empty($aDSN['dbhost']))?ini_get("mysqli.default_host"):$aDSN['dbhost'];
        $aDSN['dbuser'] = (empty($aDSN['dbuser']))?ini_get("mysqli.default_user"):$aDSN['dbuser'];
        $aDSN['dbpass'] = (empty($aDSN['dbpass']))?ini_get("mysqli.default_pw"):$aDSN['dbpass'];
        $aDSN['dbname'] = (empty($aDSN['dbname']))?'':$aDSN['dbname'];
        $aDSN['dbport'] = (empty($aDSN['dbport']))?ini_get("mysqli.default_port"):$aDSN['dbport'];
        $aDSN['dbsock']= (empty($aDSN['dbsock']))?ini_get("mysqli.default_socket"):$aDSN['dbsock'];

        // Instantiate the object by invoking the parent constructor.
        // This takes nearly 2 seconds
        parent::__construct($aDSN['dbhost'],$aDSN['dbuser'],$aDSN['dbpass'],
                            $aDSN['dbname'],$aDSN['dbport'],$aDSN['dbsock']);

        // If there are any errors, deal with them now
        if($this->connect_error){/* Do some stuff */}
    }
}

Why does calling this constructor take so long and how can I fix it?

+3
source share
2 answers

, TCP/IP , . . PHP 5.3. , "p:", "p: localhost" . PHP.INI: mysqli.allow_persistent = On

, .

, 1,3 . , 4 5 AJAX, , 7 8 . ajax PHP script, , , . , , .

PHP , , script. 1 , .

, , "" , . manual, : . , .

+1

tcp-? , DNS, , , , , DNS- mysql.

. mysql - user@example.com, MySQL DNS IP-, , , example.com IP-.

0

All Articles