/**
* _getTableFromString
*
* @param string $tableName
* @return Zend_Db_Table_Abstract
*/
protected function _getTableFromString($tableName)
{
if ($this->_table instanceof Zend_Db_Table_Abstract) {
$tableDefinition = $this->_table->getDefinition();
if ($tableDefinition !== null && $tableDefinition->hasTableConfig($tableName)) {
return new Zend_Db_Table($tableName, $tableDefinition);
}
}
// assume the tableName is the class name
if (!class_exists($tableName)) {
try {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($tableName);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_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[Zend_Db_Table_Abstract::DEFINITION] = $tableDefinition;
}
return new $tableName($options);
}