我是cakephp的新手,尽管我在codeigniter工作,因此具有MVC知识。所以我的控制器posts_controller.php是:

<?php
class PostsController extends AppController {

    public $helpers = array('Html', 'Form');



    public function index() {
         $this->set('posts', $this->Post->find('all'));
    }
}


型号Post.php为:

<?php
class Post extends AppModel {

}


我在数据库中创建了一个表posts,并添加了一些数据。但是当我运行控制器http://localhost/cake1.3/index.php/posts时,它说


  缺少数据库表
  
  错误:找不到模型发布的数据库表发布。
  
  注意:如果要自定义此错误消息,请创建
  应用程序\视图\错误\ missing_table.ctp


代码有什么问题?

注意:我需要使用cakephp version 1.3

最佳答案

错误:找不到模型发布的数据库表发布。


该错误表明数据库中没有“ posts”表。

几个解决方案:


检查您的数据库连接App-> config-> database.php,并确保一切正确。
确保数据库中有一个名为“ posts”的表

关于mysql - 找不到数据库表cakephp,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20240041/

10-11 02:25
查看更多