zend framework class初始化的问题

hxsying 2011-03-19 08:12:49
<?php
class Db extends Zend_Db_Table {
function __construct($name='',$primary=''){
echo "*****$name******";
}
public function setName($name){
$this->_name = $name;
}
public function setPrimary($primary){
$this->_primary = $primary;
}
}

function indexAction(){
$artiClass = new Db('b_arti_class','id');

}

的结果
***********
Catchable fatal error: Argument 1 passed to Zend_Db_Select::__construct() must be an instance of Zend_Db_Adapter_Abstract, null given, called in D:\Soft\wamp\www\library\Zend\Db\Table\Select.php on line 76 and defined in D:\Soft\wamp\www\library\Zend\Db\Select.php on line 163
...全文
161 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
bloodynumen 2011-05-06
  • 打赏
  • 举报
回复
试试看
bloodynumen 2011-05-06
  • 打赏
  • 举报
回复
public function int($name,$primary){
$this->_name = $name;
$this->_primary = $primary;
parent::init ();
}
helloyou0 2011-04-12
  • 打赏
  • 举报
回复
你贴的代码和你的出错信息没关系,
重贴!
liudng 2011-04-11
  • 打赏
  • 举报
回复
需要在配置文件中配置好数据库连接相关项.
hm446434459 2011-03-25
  • 打赏
  • 举报
回复
如果你一定要用构造器,记得在子类中调用父类的构造器
public function __construct($name,$primary)
{
$this->_name = $name;
$this->_primary = $primary;
parent::__construct();
}
hm446434459 2011-03-25
  • 打赏
  • 举报
回复
在zend_db_table 的继承类里面最好不要用构造器,用另外一个类似构造器的方法
protected function _setup()
{
$this->_name = 'category';
parent::_setup();
}
hxsying 2011-03-22
  • 打赏
  • 举报
回复
为什么不输出 *****b_arti_class****** 呢
zhang6464 2011-03-20
  • 打赏
  • 举报
回复
提示的错误是Zend_Db_Select这个类的构造失败,提交的必须是一个实例
hxsying 2011-03-19
  • 打赏
  • 举报
回复
嗯嗯 没人
hxsying 2011-03-19
  • 打赏
  • 举报
回复
来人呐

4,250

社区成员

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

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