I'm working in a CakePHP Model class, writing a function that is supposed to perform a whole bunch of manipulations on the model. I'm trying to follow the skinny controller, fat model idea. However, I don't seem to be able to call any of the model's functions from with in my model. Something hasn't been initialized yet, because I get an SQL error when I do:
Warning (512): SQL Error: 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 '' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 681]
Query: SHOW FULL COLUMNS FROM
It looks as if the table name hasn't been set internally somewhere. My model looks like this:
class Search extends AppModel {
var $name='Search';
var $hasMany = 'SearchResult';
var $actsAs = array('Containable');
function search($query) {
$this->create();
$this->set('query', $query);
$this->save();
}
}
I know everything the Model needs has already been created works find, because calling that exact same sequence of functions works fine from the Model controller. Like so:
function search($query) {
$this->Search->create();
$this->Search->set('query', $query);
$this->Search->save();
}
That works fine. So what gives? What's going on here?