getView()->fetch()获取不到对象??

#1 懷♀唸

代码:
$this->data=spDB("caigouhead")->findSql("select a.*,b.name from ".$GLOBALS['G_SP']['db']['prefix']."caigouhead as a left join ".$GLOBALS['G_SP']['db']['prefix']."warehouse b on a.warehouse_id=b.id where a.sn like '%".$this->spArgs("keywords")."%'");

$res=array("error"=>"0","content"=>$this->getView()->fetch("caigou/caigou.html"));
出这种错误一般是什么原因?
Fatal error: Call to a member function fetch() on a non-object


怎么会获取不到对象呢?也可以直接输出变量data的内容。




2013-04-04 11:10:35

#2 jake

猜测是getView里面的对象没有实例化,检查一下控制器的构造函数,是否已经加上

parent::__construct();

来启动父类控制器构造函数实例化getView对象。

2013-04-04 11:35:33

#3 懷♀唸

问题已解决!非常感谢

2013-04-04 12:33:46