close #48 add multi DB object instance caching support

This commit is contained in:
Exodus4D
2015-10-11 19:10:29 +02:00
parent 4770fc771d
commit f0ea85bcd0
8 changed files with 87 additions and 58 deletions

View File

@@ -99,24 +99,20 @@ class System extends \Controller\AccessController {
$systemModels = [];
// switch DB
$this->setDB('CCP');
$ccpDB = $this->getDB('CCP');
$this->whereQuery = "WHERE
map_sys." . $column . " IN (" . implode(',', $columnIDs) . ")";
$query = $this->_getQuery();
$rows = $this->f3->get('DB')->exec($query, null, 60 * 60 * 24);
$rows = $ccpDB->exec($query, null, 60 * 60 * 24);
// format result
$mapper = new Mapper\CcpSystemsMapper($rows);
$ccpSystemsData = $mapper->getData();
// switch DB
$this->setDB('PF');
foreach($ccpSystemsData as $ccpSystemData){
$system = Model\BasicModel::getNew('SystemModel');
$system->setData($ccpSystemData);
@@ -132,12 +128,11 @@ class System extends \Controller\AccessController {
*/
public function getSystems(){
// switch DB
$this->setDB('CCP');
$ccpDB = $this->getDB('CCP');
$query = $this->_getQuery();
$rows = $this->f3->get('DB')->exec($query, null, 60 * 60 * 24);
$rows = $ccpDB->exec($query, null, 60 * 60 * 24);
// format result
$mapper = new Mapper\CcpSystemsMapper($rows);
@@ -152,9 +147,7 @@ class System extends \Controller\AccessController {
*/
public function search($f3, $params){
// switch DB
\DB\Database::instance();
$this->setDB('CCP');
$ccpDB = $this->getDB('CCP');
$searchToken = '';
// check for search parameter
@@ -167,7 +160,7 @@ class System extends \Controller\AccessController {
$query = $this->_getQuery();
$rows = $f3->get('DB')->exec($query);
$rows = $ccpDB->exec($query);
// format result
$mapper = new Mapper\CcpSystemsMapper($rows);