如何使用;“设置”;在组件中,尤其是在cakephp中?
在cake php中,尤其是在cake版本1.3中,如何在组件内部使用Set函数如何使用;“设置”;在组件中,尤其是在cakephp中?,cakephp,cakephp-1.3,Cakephp,Cakephp 1.3,在cake php中,尤其是在cake版本1.3中,如何在组件内部使用Set函数 class DevicesComponent extends Object { function startup($controller) { $this->controller = $controller; } function push() { $this->set('data', $data); $this->controller
class DevicesComponent extends Object
{
function startup($controller)
{
$this->controller = $controller;
}
function push()
{
$this->set('data', $data);
$this->controller->set('data', $data);
}
}
我得到以下错误
致命错误:调用未定义的方法DeviceComponent::set()
我检查了现有的相同问题,但链接不可用尝试从您的
推送功能中删除$this->set('data',$data)
:
function push()
{
$this->controller->set('data', $data);
}
public function initialize(){
$this->controller =& $controller;
}
并使用此功能代替启动
功能:
function push()
{
$this->controller->set('data', $data);
}
public function initialize(){
$this->controller =& $controller;
}
尝试从推送功能中删除$this->set('data',$data)
:
function push()
{
$this->controller->set('data', $data);
}
public function initialize(){
$this->controller =& $controller;
}
并使用此功能代替启动
功能:
function push()
{
$this->controller->set('data', $data);
}
public function initialize(){
$this->controller =& $controller;
}
只需删除行$this->set('data',$data)代码>和错误将消失。在下一行中,您已经有了通过控制器实例设置视图变量的正确语句$this->controller->set('data',$data)
只需删除行$this->set('data',$data)代码>和错误将消失。在下一行中,您已经有了通过控制器实例设置视图变量的正确语句$this->controller->set('data',$data)代码>试试这段代码,它可能会起作用
function startup(&$controller)
{
$this->controller = $controller;
}
在推送功能中
function push()
{
$this->controller->set('data', $data);
}
试试这段代码,它可能会起作用
function startup(&$controller)
{
$this->controller = $controller;
}
在推送功能中
function push()
{
$this->controller->set('data', $data);
}
是的,我也做了同样的事。。类DeviceComponent扩展对象{function startup($controller){$this->controller=$controller;}function push(){$this->controller->set('data',$data);}}}抛出错误为“致命错误:调用非对象上的成员函数集()”,为什么这是一个可接受的答案?这是不正确的。组件甚至没有beforeFilter()回调。@Steve相同的情况不起作用。。当我通过cron jobs打电话时。。我能做什么?是的我也做了同样的事。。类DeviceComponent扩展对象{function startup($controller){$this->controller=$controller;}function push(){$this->controller->set('data',$data);}}}抛出错误为“致命错误:调用非对象上的成员函数集()”,为什么这是一个可接受的答案?这是不正确的。组件甚至没有beforeFilter()回调。@Steve相同的情况不起作用。。当我通过cron jobs打电话时。。我能做什么?