简体   繁体   English

蛋糕php缺少数据库表

[英]cake php Missing Database Table

I try to migrate a cake site on a new hosting. 我尝试在新主机上迁移Cake网站。 Everything seems ok except on one sigle action. 除了一个简单的动作,一切似乎都还可以。

error : Error: Database table actualites for model Actualites was not found. 错误:错误:找不到模型Actualites的数据库表actualites。

Notice: If you want to customize this error message, create app/views/errors/missing_table.ctp 注意:如果要自定义此错误消息,请创建app / views / errors / missing_table.ctp

route '/' => acceuil controller 路线'/'=>加速控制器

<?php
class Accueil extends AppModel{
        public $name = 'Accueil';
        var $useTable = false;

        public function findPublicActualities(){

        }
}
?>


<?php
class AccueilController extends AppController{
        public $name = 'Accueil';
        public $helpers = array('Html');
        public $uses = array('Actualites');

        public function index(){
                $this->set( 'title_for_layout', 'Bienvenue' );
                $conditions = array("public" => "1");
                $actualites = $this->Actualites->find("all",
                                    array('conditions' => $conditions,
                                          'limit' => 5,
                                          'order' => 'poid ASC'));

                $this->set('actualites', $actualites);
        }
}
?>

thanks for your help, this issue make me crazy ! 感谢您的帮助,这个问题使我发疯!

in Cakephp the model name is a singular of the table name so if you have a table dogs, your model will be called Dog, so i think your problem is that you took the same model name as your table, so to fix it you can do this: 在Cakephp中,模型名称是表名称的单数,因此,如果您有桌狗,您的模型将被称为Dog,所以我认为您的问题是您使用了与表相同的模型名称,因此可以对其进行修复做这个:

 class Actualites extends AppModel {
     public $useTable = 'actualites';
 }

and it will work. 它会工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM