rabin 4 kuukautta sitten
vanhempi
commit
081aba4e76
3 muutettua tiedostoa jossa 10 lisäystä ja 4 poistoa
  1. 5 2
      src/Dever/Import.php
  2. 4 1
      src/Dever/Store/Base.php
  3. 1 1
      src/Dever/Store/Pdo.php

+ 5 - 2
src/Dever/Import.php

@@ -58,7 +58,10 @@ class Import
             Dever::error('route error');
         }
         if (method_exists($this->class, $method . '_commit') && Dever::$commit) {
-            $db = Dever::store();
+            $db = end(\Dever\Store\Pdo::$instance);
+            if (!$db) {
+                $db = Dever::store();
+            }
             try {
                 Dever::$commit = false;
                 $db->begin();
@@ -66,7 +69,7 @@ class Import
                 $db->commit();
                 return $data;
             } catch (\Exception $e) {
-                $db->rollBack();
+                $db->rollback();
                 $data = $e->getTrace();
                 Debug::trace($data);
                 throw new \Exception(json_encode($data));

+ 4 - 1
src/Dever/Store/Base.php

@@ -7,9 +7,12 @@ class Base
     protected $read;
     protected $update;
     protected $type;
-    protected static $instance;
+    public static $instance = array();
     public static function getInstance($key, $setting, $partition)
     {
+        if ($key == false) {
+            print_r(static::$instance);die;
+        }
         if (isset($partition['create']) && $partition['create'] && isset($partition['database']) && $partition['database']) {
             $key .= $partition['database'];
             $setting['name'] .= '_' . $partition['database'];

+ 1 - 1
src/Dever/Store/Pdo.php

@@ -181,7 +181,7 @@ class Pdo extends Base
                 $this->commit();
                 return $result;
             } catch (\Exception $e) {
-                $this->rollBack();
+                $this->rollback();
                 Output::error($msg);
             }
         } else {