From: Andrey Kutejko Date: Mon, 3 Jun 2013 19:48:15 +0000 (+0300) Subject: allow persistant connection to DB X-Git-Tag: 0.5~269 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=d15f9019842eb5357bc8969b0c8a0f9c98748628;p=ipf.git allow persistant connection to DB --- diff --git a/ipf/orm/manager.php b/ipf/orm/manager.php index 1c1b78a..ee2f721 100644 --- a/ipf/orm/manager.php +++ b/ipf/orm/manager.php @@ -84,7 +84,7 @@ class IPF_ORM_Manager extends IPF_ORM_Configurable implements Countable, Iterato } } - public function openConnection($adapter, $name = null, $setCurrent = true) + public function openConnection($adapter, $name = null, $setCurrent = true, $persistent = false) { if (is_object($adapter)) { if ( ! ($adapter instanceof PDO) && ! in_array('IPF_ORM_Adapter_Interface', class_implements($adapter))) { @@ -156,6 +156,8 @@ class IPF_ORM_Manager extends IPF_ORM_Configurable implements Countable, Iterato $className = $drivers[$driverName]; $conn = new $className($this, $adapter); + if ($persistent) + $conn->setOption(IPF_ORM::ATTR_PERSISTENT, true); $conn->setName($name); $conn->setCharset('utf8'); diff --git a/ipf/project.php b/ipf/project.php index 128ac60..32f1400 100644 --- a/ipf/project.php +++ b/ipf/project.php @@ -118,7 +118,8 @@ final class IPF_Project{ $dsn = IPF::get('dsn'); if ($dsn=='') throw new IPF_Exception_Panic('Specify dsn in config file'); - $conn = IPF_ORM_Manager::connection($dsn); + + IPF_ORM_Manager::getInstance()->openConnection($dsn, null, true, IPF::get('db_persistent', false)); if (IPF::get('debug')){ $this->sqlProfiler = new IPF_ORM_Connection_Profiler();