mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 09:44:55 +02:00
* support for database persistent and socket connections (performance boost)
This commit is contained in:
@@ -64,16 +64,6 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
||||
$params['port'] = $host[1];
|
||||
}
|
||||
|
||||
if( isset($params['host']) )
|
||||
{
|
||||
$dns[] = 'host=' . $params['host'];
|
||||
}
|
||||
|
||||
if( isset($params['port']) )
|
||||
{
|
||||
$dns[] = 'port=' . $params['port'];
|
||||
}
|
||||
|
||||
if( isset($params['database']) )
|
||||
{
|
||||
$dns[] = 'dbname=' . $params['database'];
|
||||
@@ -99,6 +89,10 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
||||
$this->logged = true;
|
||||
}
|
||||
|
||||
if( !isset($params['persistent']) ) {
|
||||
$params['persistent'] = false;
|
||||
}
|
||||
|
||||
global $cache, $config;
|
||||
if(isset($cache) && $cache->enabled()) {
|
||||
$tmp = null;
|
||||
@@ -123,7 +117,27 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct('mysql:' . implode(';', $dns), $user, $password);
|
||||
if(isset($params['socket'][0])) {
|
||||
$dns[] = 'unix_socket=' . $params['socket'];
|
||||
|
||||
parent::__construct('mysql:' . implode(';', $dns), $user, $password, array(
|
||||
PDO::ATTR_PERSISTENT => $params['persistent']
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( isset($params['host']) ) {
|
||||
$dns[] = 'host=' . $params['host'];
|
||||
}
|
||||
|
||||
if( isset($params['port']) ) {
|
||||
$dns[] = 'port=' . $params['port'];
|
||||
}
|
||||
|
||||
parent::__construct('mysql:' . implode(';', $dns), $user, $password, array(
|
||||
PDO::ATTR_PERSISTENT => $params['persistent']
|
||||
));
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
|
Reference in New Issue
Block a user