5
public function data()
{ 
if($old != $status || $prev_lat != $lat || $prev_long != $long)
            {
                if($status == 'Village' || 'Unknown')
                {
                    exec_query();
                }
                else if($status == 'Town' || 'City')
                {
                    exec_query();
                }   
            }
}


public function exec_query()
{
    //Some data;
}

但是每当我调用此函数时,我都会收到如下错误:-

Call to undefined function exec_query() 

谁能告诉我在 cakephp 中调用函数

4

1 回答 1

15

在函数名称前添加$this->如下:

public function data()
{ 
if($old != $status || $prev_lat != $lat || $prev_long != $long)
            {
                if($status == 'Village' || 'Unknown')
                {
                    $this->exec_query();
                }
                else if($status == 'Town' || 'City')
                {
                    $this->exec_query();
                }   
            }
}


public function exec_query()
{
    //Some data;
}
于 2013-03-27T09:24:41.717 回答