I am trying to do a query inside my model and call it in my controller, but for some reason I get some errors. Here is my model:
class Room extends AppModel {
var $name = 'Room';
var $displayField = 'title';
var $actsAs = array('Containable');
function select($qwe){
$results = $this->Room->query("SELECT * FROM test WHERE qwe= ".$qwe." ");
}
In this case, I get Undefined property: Room::$room. In the controller I have:
...
function success(){
$qwe = "testing"
$this->set('get', $this->Room->select($qwe));
}
}
Any idea about what am I doing wrong?
You are calling within a Model so
should be
because
query()is a method of Class Model which is the parent class of every other Model, Model Room has no property Room that’s why causing the error. If you would call this function via controller then you use$this->ModelName->method()Your function
selectisn’t returning anything, you should change it to