我都有兩個表類相冊和如下類別:Zend_Db_Table類關係的文件或找不到類
class Application_Model_DbTable_Albums extends Zend_Db_Table_Abstract
{
protected $_name = 'albums';
private $_custom_message = '';
protected $_referenceMap = array(
'CategoryTypes' => array(
'columns' => array('category_id'),
'refTableClass' => 'Category',
'refColumns' => array('id')
)
);
}
class Application_Model_DbTable_Category extends Zend_Db_Table_Abstract {
protected $_name = 'category';
protected $_dependentTables = array('Albums');
}
在我的IndexController編輯操作,我有以下代碼:
$category = new Application_Model_DbTable_Category();
$cat_id = $category->find(1);
$cat_3 = $cat_id->current();
$user_cat = $cat_3->findDependentRowset('Albums');
而且我得到這個異常消息。註釋$ user_cat將不會得到異常消息
Exception information:
Message: File "Albums.php" does not exist or class "Albums" was not found in the file
Stack trace:
#0 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Db\Table\Row\Abstract.php(872): Zend_Db_Table_Row_Abstract->_getTableFromString('Albums')
#1 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\application\controllers\IndexController.php(187): Zend_Db_Table_Row_Abstract->findDependentRowset('Albums')
#2 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Controller\Action.php(516): IndexController->editAction()
#3 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('editAction')
#4 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#5 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#6 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#7 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\public\index.php(49): Zend_Application->run()
#8 {main}
我的相冊類是有,但不知道爲什麼它說找不到類或文件
叫什麼名字和包含'Application_Model_DbTable_Albums'類文件的路徑?它必須是'application/models/DbTable/Alumbs.php'才能被自動加載。 – drew010
是的,這是正確的路徑 – redcoder