{
$this->container = $container;
$this->project_root = $container['settings']->get('project_root');
+ IPF_ORM_Manager::getInstance()->setContainer($container);
}
private static $appModels = array();
+++ /dev/null
-<?php
-
-class IPF_ORM_Middleware extends IPF_Middleware
-{
- function processRequest($request)
- {
- $pdo = $this->container['db']->getWrappedConnection();
- IPF_ORM_Manager::getInstance()->setConnection($pdo);
- return false;
- }
-}
protected $_connection = null;
protected $_queryRegistry;
public $dbListeners = array();
+ private $_container = null;
private function __construct()
{
return IPF_ORM_Manager::getInstance()->getCurrentConnection();
}
- public function setConnection(PDO $pdo)
+ public function setContainer($container)
{
- $this->_connection = new IPF_ORM_Connection_Mysql($this, $pdo);
+ $this->_container = $container;
}
public function getCurrentConnection()
{
+ if ($this->_connection === null) {
+ $pdo = $this->_container['db']->getWrappedConnection();
+ $this->_connection = new IPF_ORM_Connection_Mysql($this, $pdo);
+ }
return $this->_connection;
}
return "<pre>\nIPF_ORM_Manager\n</pre>";
}
}
-