Reputation: 21945
I've created a simple method in mo controller, like so:
public function getAddresses() {
$addresses = $this->Adres->find('all');
return $addresses;
}
When I call this in a controller, like so:
$this->loadModel('Adres');
$sponsors = $this->Adres->getAddresses();
I get this strange error:
Database Error Error: 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 'getAddresses' at line 1 SQL Query: getAddresses
What did I do wrong?
Upvotes: 0
Views: 454
Reputation: 7882
That's because here you are calling the method on the model
$this->loadModel('Adres');
$sponsors = $this->Adres->getAddresses();
When you clearly stated in your first sentence that the method is on the controller. Move the method to the Adres
model and you should be good!
Upvotes: 2