Browse Source

Update 'src/DDLWrapper/Wrapper.php'

ahwelp 7 năm trước cách đây
mục cha
commit
a66a603bc6
1 tập tin đã thay đổi với 13 bổ sung1 xóa
  1. 13 1
      src/DDLWrapper/Wrapper.php

+ 13 - 1
src/DDLWrapper/Wrapper.php

@@ -3,6 +3,7 @@
 namespace DDLWrapper;
 
 use DDLWrapper\Db\Table as Table;
+
 use DDLWrapper\Db\Adapter\PostgresAdapter;
 use DDLWrapper\Db\Adapter\MysqlAdapter;
 use DDLWrapper\Db\Adapter\SQLiteAdapter;
@@ -13,6 +14,7 @@ class Wrapper{
     private static $_instance;
 
     public $_adapter;
+    public $_driver;
 
     function __construct(){ }
 
@@ -34,13 +36,16 @@ class Wrapper{
 
     public static function set_driver(\PDO $driver){
         $instance = self::getInstance();
+        $instance->_driver = $driver;
 
-        switch ($driver->driver){
+        switch ($driver->getAttribute(\PDO::ATTR_DRIVER_NAME)){
             case 'sqlite':
                 $instance->_adapter = new SQLiteAdapter();
                 $instance-> _adapter->setConnection($driver);
                 break;
             case 'pgsql':
+                $instance->_adapter = new PostgresAdapter();
+                $instance->_adapter->setConnection($driver);
                 break;
             case 'mysql':
                 break;
@@ -59,8 +64,15 @@ class Wrapper{
         $instance = self::getInstance();
         $instance->_adapter->beginTransaction();
     }
+
     public static function commit(){
         $instance = self::getInstance();
         $instance->_adapter->commitTransaction();
     }
+
+    public static function exec($sql){
+        $instance = self::getInstance();
+        $instance->_driver->exec($sql);
+    }
+
 }