CakePHP 2.6: Getting PDO Exception on calling model function in controller

75 Views Asked by At

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'getStateCity' at line 1

Following code is working:

$

response['data'] =  $this->StateZip->find('first', array(
                                'fields' => array('StateZip.state', 'StateZip.city', 'StateZip.zip'),
                                'conditions' => array('StateZip.zip' => $zip)));

However same is not working if called through model function

 $response['data'] = $this->StateZip->getStateCity($zip);

Content of getStateCity is

public function getStateCity($zip){
        $response = array('status'=>'error','data'=>'');

        $data = $this->find('first', array(
                'fields' => array('StateZip.state', 'StateZip.city', 'StateZip.zip'),
                'conditions' => array('StateZip.zip' => $zip)
        ));

        return $data;
    }

Any help and suggestions will be helpful.

0

There are 0 best solutions below