I've got a problem very similar to the ones found here and here, but these solutions aren't helping me fix my version of the problem. I'm using CakePHP 1.3 and I'm trying to call some model functions from within a view controller:
//Class setup
var $uses = array('StudentsTelephone', 'AddressesStudent');
//...
function someFunction(){
$this->set('telephones', $this->StudentsTelephone->getActiveStudentTelepone($id));
$this->set('addresses', $this->AddressesStudent->getActiveByStudentId($id));
}
This first of the model function calls (StudentsTelephone) works, but the second (AddressesStudent) fails. It attempts to use the function name as the SQL call resulting in:
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 'getActiveByStudentId' at line 1 [CORE\cake\libs\model\datasources\dbo_source.php, line 684]
Using a little bit of debugging, I find out that the function is being looked for in the AppModel and AddressesStudent is never checked. Based on those other solutions it looks like it should be a typo in the name. However, everything appears to be correctly named. The above code is as stated, the model file is addresses_student.php
, the class name is AddressesStudent and this was working fine before I updated Cake (just recently switched from 1.1 to 1.3). Any suggestions as to what might be causing the problem is not a naming error? Or maybe some other naming error that I'm missing? Thank you much!
EDIT: Also, here's the backtrace telling me that the model PHP file was never found:
DboSource::showQuery() - CORE\cake\libs\model\datasources\dbo_source.php, line 684
DboSource::execute() - CORE\cake\libs\model\datasources\dbo_source.php, line 266
DboSource::fetchAll() - CORE\cake\libs\model\datasources\dbo_source.php, line 410
DboSource::query() - CORE\cake\libs\model\datasources\dbo_source.php, line 364
Model::call__() - CORE\cake\libs\model\model.php, line 502
Overloadable::__call() - CORE\cake\libs\overloadable_php5.php, line 50
AppModel::getActiveByStudentId() - [internal], line ??
StudentsController::edit() - APP\controllers\students_controller.php, line 277
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
[main] - APP\webroot\index.php, line 83