示例#1
0
 /**
  * _getTableFromString
  *
  * @param string $tableName
  * @return JO_Db_Table_Abstract
  */
 protected function _getTableFromString($tableName)
 {
     if ($this->_table instanceof JO_Db_Table_Abstract) {
         $tableDefinition = $this->_table->getDefinition();
         if ($tableDefinition !== null && $tableDefinition->hasTableConfig($tableName)) {
             return new JO_Db_Table($tableName, $tableDefinition);
         }
     }
     // assume the tableName is the class name
     if (!class_exists($tableName)) {
         try {
             require_once 'JO/Loader.php';
             JO_Loader::loadClass($tableName);
         } catch (JO_Exception $e) {
             require_once 'JO/Db/Table/Row/Exception.php';
             throw new JO_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e);
         }
     }
     $options = array();
     if ($table = $this->_getTable()) {
         $options['db'] = $table->getAdapter();
     }
     if (isset($tableDefinition) && $tableDefinition !== null) {
         $options[JO_Db_Table_Abstract::DEFINITION] = $tableDefinition;
     }
     return new $tableName($options);
 }