Manoj K
Manoj K

Reputation: 389

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

Upvotes: 5

Views: 9964

Answers (1)

Alessandro Minoccheri
Alessandro Minoccheri

Reputation: 35973

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

Upvotes: 15

Related Questions