示例#1
0
 /**
  * Initialize the Database Connections (instances of IfwPsn_Vendor_Zend_Db_Table_Abstract)
  *
  * @return IfwPsn_Vendor_Zend_Application_Resource_Multidb
  */
 public function init()
 {
     $options = $this->getOptions();
     if (isset($options['defaultMetadataCache'])) {
         $this->_setDefaultMetadataCache($options['defaultMetadataCache']);
         unset($options['defaultMetadataCache']);
     }
     foreach ($options as $id => $params) {
         $adapter = $params['adapter'];
         $default = (int) (isset($params['isDefaultTableAdapter']) && $params['isDefaultTableAdapter'] || isset($params['default']) && $params['default']);
         unset($params['adapter'], $params['default'], $params['isDefaultTableAdapter']);
         $this->_dbs[$id] = IfwPsn_Vendor_Zend_Db::factory($adapter, $params);
         if ($default) {
             $this->_setDefault($this->_dbs[$id]);
         }
     }
     return $this;
 }
示例#2
0
文件: Db.php 项目: jasmun/Noco100
 /**
  * Retrieve initialized DB connection
  *
  * @return null|IfwPsn_Vendor_Zend_Db_Adapter_Abstract
  */
 public function getDbAdapter()
 {
     if (null === $this->_db && null !== ($adapter = $this->getAdapter())) {
         $this->_db = IfwPsn_Vendor_Zend_Db::factory($adapter, $this->getParams());
         if ($this->_db instanceof IfwPsn_Vendor_Zend_Db_Adapter_Abstract && $this->isDefaultTableAdapter()) {
             IfwPsn_Vendor_Zend_Db_Table::setDefaultAdapter($this->_db);
         }
     }
     return $this->_db;
 }