Cakephp 2.0, controller doesn't see model -
i'm busy upgrading site client of mine. it's first time working cakephp , i'm running issues.
i created table named banners
inside database, , made following files:
model/banner.php controllers/bannerscontroller.php view/banners/admin_index.ctp
it seems controller can't find model. whenever try load page admin_index.ctp
following message: error: internal error has occurred.
if replace contents of public admin_index()
, make echo text, work.
i tried adding form admin_index.ctp
doing this
echo $this->form->create('banner');
this gives me error: internal error has occurred.
i have set model, controller, view , database way others posts, pages, etc set , can't seem work. have idea on how fix this?
kind regards,
nick
<?php class banner extends appmodel { } ?> <?php class bannerscontroller extends appcontroller { public $helpers = array('html', 'form'); public function admin_index(){ $banners = $this->banner->find('all'); $this->set('banners', $banners); } ?> stack trace: #0 /srv/nkuchiki/www/www.kuchiki.nl/app/webroot/index.php(111): dispatcher->dispatch(object(cakerequest), object(cakeresponse)) #1 {main} 2015-04-10 17:29:43 error: [missingtableexception] table banners model banner not found in datasource default. exception attributes: array ( 'table' => 'banners', 'class' => 'banner', 'ds' => 'default', ) request url: /admin/banners stack trace: #0 /srv/nkuchiki/www/www.kuchiki.nl/lib/cake/model/model.php(3501): model->setsource('banners') #1 /srv/nkuchiki/www/www.kuchiki.nl/lib/cake/model/model.php(2905): model->getdatasource() #2 /srv/nkuchiki/www/www.kuchiki.nl/lib/cake/model/model.php(2877): model->_readdatasource('all', array) #3 /srv/nkuchiki/www/www.kuchiki.nl/app/controller/bannerscontroller.php(7): model->find('all') #4 [internal function]: bannerscontroller->admin_index() #5 /srv/nkuchiki/www/www.kuchiki.nl/lib/cake/controller/controller.php(490): reflectionmethod->invokeargs(object(bannerscontroller), array) #6 /srv/nkuchiki/www/www.kuchiki.nl/lib/cake/routing/dispatcher.php(191): controller->invokeaction(object(cakerequest)) #7 /srv/nkuchiki/www/www.kuchiki.nl/lib/cake/routing/dispatcher.php(165): dispatcher->_invoke(object(bannerscontroller), object(cakerequest)) #8 /srv/nkuchiki/www/www.kuchiki.nl/app/webroot/index.php(111): dispatcher->dispatch(object(cakerequest), object(cakeresponse)) #9 {main}
thanks advice guys. based on extended error message did research on google , found other threads on stackoverflow.
i removed files in tmp/cache/models, , tmp/cache/persistent , problem resolved :-).
it can difficult find problem when seems programmed right.