From d15f9019842eb5357bc8969b0c8a0f9c98748628 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Mon, 3 Jun 2013 22:48:15 +0300 Subject: [PATCH] allow persistant connection to DB --- ipf/orm/manager.php | 4 +++- ipf/project.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) 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(); -- 2.49.0