Update 'src/DDLWrapper/Wrapper.php'

This commit is contained in:
ahwelp
2018-12-21 10:46:20 +00:00
parent 2fd1cdd949
commit a66a603bc6
+13 -1
View File
@@ -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);
}
}