If you have caching enabled be sure to clear the tmp/cache/models dir. On Thu, Aug 2, 2012 at 9:24 AM, WhyNotSmile <[email protected]> wrote: > Hmmm... I removed the Conference association and it's still not working. > I've decided to give up on that bit and just put the function into the > controller for now, and that seems to be working fine. > > Thanks for the help though. > > > > On Thursday, 2 August 2012 12:44:07 UTC+1, majna wrote: >> >> Yeah, changing order affects only 1.3 apps as 2.x models are lazy loaded. >> I tested that code you pasted and Confcommittee::myFunction() (without >> belongsTo association to Conference) works just fine. >> >> What code do you have in AppController::beforeFilter()? >> >> On Thursday, August 2, 2012 12:13:37 PM UTC+2, WhyNotSmile wrote: >>> >>> Hi manja, thanks for your help, but it's not inside a plugin, and >>> changing the order didn't make any difference. >>> >>> >>> >>> On Wednesday, 1 August 2012 21:41:12 UTC+1, majna wrote: >>>> >>>> If it's not the plugin issue, then Conference model is associated with >>>> Confcommittee with wrong 'class' name. >>>> You can test that if you change order in $uses: >>>> public $uses = array('Confcommittee', 'Conference'); >>>> >>>> On Wednesday, August 1, 2012 10:35:12 PM UTC+2, majna wrote: >>>>> >>>>> Is this code inside a plugin? >>>>> >>>>> 2012/8/1 WhyNotSmile >>>>>> >>>>>> 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 >>>>>>>>> → PDOStatement->execute(array) >>>>>>>>> >>>>>>>>> CORE\Cake\Model\Datasource\DboSource.php line 403 >>>>>>>>> → DboSource->_execute(string, array) >>>>>>>>> >>>>>>>>> CORE\Cake\Model\Datasource\DboSource.php line 647 >>>>>>>>> → DboSource->execute(string, array, array) >>>>>>>>> >>>>>>>>> CORE\Cake\Model\Datasource\DboSource.php line 589 >>>>>>>>> → DboSource->fetchAll(string, array, array) >>>>>>>>> >>>>>>>>> CORE\Cake\Model\Model.php line 775 >>>>>>>>> → DboSource->query(string, array, AppModel) >>>>>>>>> >>>>>>>>> APP\Controller\ConferencesController.php line 96 >>>>>>>>> → Model->__call(string, array) >>>>>>>>> >>>>>>>>> APP\Controller\ConferencesController.php line 96 >>>>>>>>> → AppModel->myFunction() >>>>>>>>> >>>>>>>>> [internal function] >>>>>>>>> → ConferencesController->admin_manage(string) >>>>>>>>> >>>>>>>>> CORE\Cake\Controller\Controller.php line 485 >>>>>>>>> → ReflectionMethod->invokeArgs(ConferencesController, array) >>>>>>>>> >>>>>>>>> CORE\Cake\Routing\Dispatcher.php line 103 >>>>>>>>> → Controller->invokeAction(CakeRequest) >>>>>>>>> >>>>>>>>> CORE\Cake\Routing\Dispatcher.php line 85 >>>>>>>>> → Dispatcher->_invoke(ConferencesController, CakeRequest, >>>>>>>>> CakeResponse) >>>>>>>>> >>>>>>>>> APP\webroot\index.php line 92 >>>>>>>>> → Dispatcher->dispatch(CakeRequest, CakeResponse) >>>>>>>> >>>>>>>> >>>>>>>> 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 >>>>>> [email protected] For more options, visit this >>>>>> group at http://groups.google.com/group/cake-php >>>>> >>>>> > -- > 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 > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php
-- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
