Calling functions in cakephp

cakephp, function, php

Solution

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

Problem

``` 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

Original source