Thanks for the help, but it hasn't made any difference. I'm totally baffled, because I've used the same code in other places with different model names, and it seems fine... I must have just missed something on copying it.
On Wednesday, 1 August 2012 20:58:42 UTC+1, majna wrote: > > Model Confcommittee is not found, so Cake creates an instance of AppModel. > You are using $uses property, so try to add in Model/Confcommittee.php: > > App::uses('Confcommittee ', 'Model'); > > class Confcommittee extends AppModel { ... > > Btw, you don't need to call exit() after redirect() in that controller. > > > On Wednesday, August 1, 2012 5:44:18 PM UTC+2, WhyNotSmile wrote: >> >> I'm using Cake 2.0, and getting a database error when I call a particular >> model. I think I've probably named something wrongly, but I can't see what! >> >> I have the following: >> >> *DB table:* confcommittees >> >> *Model/Confcommittee.php:* >> >>> class Confcommittee extends AppModel { >>> public $name = 'Confcommittee'; >>> >>> var $belongsTo = array('Conference'); >>> >>> public function myFunction() { >>> return false; >>> } >>> } >> >> >> *Controller/ConferencesController.php:* >> >>> App::uses('AppController', 'Controller'); >>> >>> class ConferencesController extends AppController { >>> public $name = 'Conferences'; >>> public $helpers = array('Html', 'Session'); >>> public $uses = array('Conference', 'Confcommittee'); >>> >>> /* Filters and callbacks */ >>> function beforeFilter() { >>> parent::beforeFilter(); >>> } >>> /* >>> * admin_manage >>> * Allows the admin user to manage any given conference >>> */ >>> function admin_manage($conference_id = null) { >>> if(!$conference_id) { >>> $this->redirect('/admin/conferences/main'); >>> exit; >>> } >>> $this->Confcommittee->myFunction(); >>> } >>> } >>> >>> When I access admin/conferences/manage, I get the following 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 'myFunction' at line 1 >>> *SQL Query: *myFunction >>> *Notice: *If you want to customize this error message, create >>> app\View\Errors\pdo_error.ctp >>> Stack Trace >>> >>> - CORE\Cake\Model\Datasource\DboSource.php line >>> 437<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → >>> PDOStatement->execute(array)<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - CORE\Cake\Model\Datasource\DboSource.php line >>> 403<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → DboSource->_execute(string, >>> array)<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - CORE\Cake\Model\Datasource\DboSource.php line >>> 647<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → DboSource->execute(string, array, >>> array)<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - CORE\Cake\Model\Datasource\DboSource.php line >>> 589<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → DboSource->fetchAll(string, array, >>> array)<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - CORE\Cake\Model\Model.php line >>> 775<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → DboSource->query(string, array, >>> AppModel)<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - APP\Controller\ConferencesController.php line >>> 96<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → Model->__call(string, >>> array)<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - APP\Controller\ConferencesController.php line >>> 96<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → >>> AppModel->myFunction()<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - [internal >>> function]<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → >>> ConferencesController->admin_manage(string)<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - CORE\Cake\Controller\Controller.php line >>> 485<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → ReflectionMethod->invokeArgs(ConferencesController, >>> array)<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - CORE\Cake\Routing\Dispatcher.php line >>> 103<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → >>> Controller->invokeAction(CakeRequest)<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - CORE\Cake\Routing\Dispatcher.php line >>> 85<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → Dispatcher->_invoke(ConferencesController, CakeRequest, >>> CakeResponse) <http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >>> - APP\webroot\index.php line >>> 92<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> → Dispatcher->dispatch(CakeRequest, >>> CakeResponse)<http://localhost/IAAD_New/admin/conferences/manage/1#> >>> >>> >> As I said, I think I've given something the wrong name, but I can't find >> it. Can anyone help?! >> > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php