From a66a603bc6e7c6c3ace49af29b72a80ac491cc1b Mon Sep 17 00:00:00 2001 From: ahwelp Date: Fri, 21 Dec 2018 10:46:20 +0000 Subject: [PATCH] Update 'src/DDLWrapper/Wrapper.php' --- src/DDLWrapper/Wrapper.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/DDLWrapper/Wrapper.php b/src/DDLWrapper/Wrapper.php index 5925847..03e3e12 100644 --- a/src/DDLWrapper/Wrapper.php +++ b/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); + } + } \ No newline at end of file