Zend framework 如何载入类模型类

yniissy 2012-02-07 06:28:57
我的zend framework有两个模块一个是工admin 和default 我在default 里的models 里加入message.php
<?php
class Message extends Zend_Db_Table

{
protected $_name ="message";
protected $_primary = 'id';

/*
* 取到所有的留言
*/
public function getAllMessage(){
$messageArray=$this->fetchAll("message.pid=0","message.id DESC")->toArray();
return $messageArray;
}

/*
* 取到所有的回复留言数据
*/
public function getAllReMessage(){
$ReArray=$this->fetchAll("message.pid!=0","message.id DESC")->toArray();
return $ReArray;
}

/*
* 根据ID取留言数据
*/
public function getMessageByID($id){
$messageone=$this->fetchAll('id='.$id)->toArray();
return $messageone;
}

/*
* 修改留言
*/
public function updateMessageByID($array,$id){
$db = $this->getAdapter();
$where=$db->quoteInto('id = ?', $id);
$this->update($array, $where);
}
/*
* 删除留言
*/
public function delMessageByID($id){
$where = 'id = ' . $id;
$this->delete($where);
return true;
}
}



而在dedault里的testController.php里

<?php
class TestController extends Zend_Controller_Action{

public function init(){


}


public function indexAction(){


$message=new message();

}


}
?>


就出现错误

Notice: Undefined index: second in C:\wamp\www\cs\library\Zend\Date.php on line 2259

Fatal error: Class 'message' not found in C:\wamp\www\cs\application\modules\default\controllers\testController.php on line 15

我如何载入类呢?
...全文
249 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zoe380303793 2012-05-31
  • 打赏
  • 举报
回复
1、在你的包含路径里添加对models引用
2、在引导文件或入口文件里添加$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
huolin 2012-04-16
  • 打赏
  • 举报
回复
也遇到同样的问题的http://topic.csdn.net/u/20120416/11/47e823e1-79ea-468e-a9a8-4b173fbc8289.html

框架不会自动在同模块的根目录里自动查找models文件夹里的类文件吗?
coder 2012-04-16
  • 打赏
  • 举报
回复
里面已经回了。
http://topic.csdn.net/u/20120416/11/47e823e1-79ea-468e-a9a8-4b173fbc8289.html
asasdaf 2012-02-07
  • 打赏
  • 举报
回复
注意大小写的区别
ohmygirl 2012-02-07
  • 打赏
  • 举报
回复
Message 放入zend framework的include path

也可以在入口文件中添加require代码引入类
asasdaf 2012-02-07
  • 打赏
  • 举报
回复
你需要保证,类的文件名和类名是相等的。
就是文件名是message.php,那么类名就是message

4,250

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧