From: Andrey Kutejko Date: Fri, 15 Mar 2019 00:04:07 +0000 (+0100) Subject: add configuration middleware X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=45b8efe7b58dbb280483465dfc4fd0baa853a016;p=ipf-legacy-orm.git add configuration middleware --- diff --git a/src/middleware.php b/src/middleware.php new file mode 100644 index 0000000..5fc3db0 --- /dev/null +++ b/src/middleware.php @@ -0,0 +1,11 @@ +container['db']->getWrappedConnection(); + IPF_ORM_Manager::getInstance()->setConnection($pdo); + return false; + } +} diff --git a/src/orm/manager.php b/src/orm/manager.php index 570de33..1bb530d 100644 --- a/src/orm/manager.php +++ b/src/orm/manager.php @@ -46,12 +46,13 @@ class IPF_ORM_Manager extends IPF_ORM_Configurable return IPF_ORM_Manager::getInstance()->getCurrentConnection(); } + public function setConnection(PDO $pdo) + { + $this->_connection = new IPF_ORM_Connection_Mysql($this, $pdo); + } + public function getCurrentConnection() { - if (!$this->_connection) { - $pdo = \PFF\Container::databaseConnection(); - $this->_connection = new IPF_ORM_Connection_Mysql($this, $pdo); - } return $this->_connection; }