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.