]> git.andy128k.dev Git - ipf.git/commitdiff
allow persistant connection to DB
authorAndrey Kutejko <andy128k@gmail.com>
Mon, 3 Jun 2013 19:48:15 +0000 (22:48 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Mon, 3 Jun 2013 19:48:15 +0000 (22:48 +0300)
ipf/orm/manager.php
ipf/project.php

index 1c1b78a344675e05d4971b8806ff1497f6b2cce5..ee2f721d229832bc6e955e21e35d4492279b75af 100644 (file)
@@ -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');
 
index 128ac600cfc10946d44889e258cd51f970ae1ed8..32f14003bb5d1906515c267df1e729d92e193f51 100644 (file)
@@ -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();