0
我有一個文件夾結構像this,我試圖加載News
模型我的控制器內:問題加載模式與Zend框架模塊
<?php
/**
* Login
*/
class Admin_NewsController extends Zend_Controller_Action {
public function preDispatch() {
$layout = Zend_Layout::getMvcInstance();
$layout->setLayout('admin');
}
public function init() {
$this->db = new Application_Admin_Model_DbTable_News();
}
public function indexAction() {
}
public function addAction() {
//$this->getHelper('viewRenderer')->setNoRender();
// Calls the Request object
$request = $this->getRequest();
if ($request->isPost()) {
// Retrieves form data
$data = array(
"new_title" => $request->getParam('txtTitle'),
"new_text" => htmlentities($request->getParam('txtNews')),
"new_image" => $request->getParam('upName'),
"new_published" => 1
);
// Inserts in the database
if ($this->db->addNews($data)) {
$this->view->output = 1;
} else {
$this->view->output = 0;
}
} else {
$this->view->output = 0;
}
$this->_helper->layout->disableLayout();
}
}
而且我模式:
<?php
class Application_Admin_Model_DbTable_News extends Zend_Db_Table_Abstract
{
protected $_name = 'news';
public function addNews($data) {
$this->insert($data);
}
}
Althoug我得到這個錯誤:
確定更多的模塊中自動加載,但現在它說'致命錯誤:類「Admin_Model_DbTable_News」不found' – 2010-09-01 16:46:57
我一定要使用一些自動加載磁帶機? – 2010-09-01 16:52:53
您需要確保的唯一一件事就是您的模塊引導程序正在擴展Zend_Application_Module_Bootstrap,如下所示: class News_Bootstrap擴展了Zend_Application_Module_Bootstrap – Vika 2010-09-01 18:18:48