Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling functions in cakephp

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;
}

But whenever i call this function i get error like:-

Call to undefined function exec_query() 

Can anyone tell me hw to call a function in cakephp

like image 383
Manoj K Avatar asked Mar 27 '13 09:03

Manoj K


1 Answers

Add $this-> before the name of the function like 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;
}
like image 163
Alessandro Minoccheri Avatar answered Nov 20 '22 22:11

Alessandro Minoccheri