简体   繁体   English

找不到数据库表cakephp

[英]Database table not found cakephp

I am new to cakephp , though I have worked in codeigniter hence having MVC knowledge. 我是cakephp新手,尽管我曾在codeigniter工作,因此拥有MVC知识。 So my controller posts_controller.php is: 所以我的控制器posts_controller.php是:

<?php
class PostsController extends AppController {

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



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

Model Post.php is : 模型Post.php是:

<?php
class Post extends AppModel {

}

I have created a table posts in my database and added some data. 我在数据库中创建了一个表posts ,并添加了一些数据。 But when I run my controoler http://localhost/cake1.3/index.php/posts it says 但是当我运行控制器http://localhost/cake1.3/index.php/posts它说

Missing Database Table 缺少数据库表

Error: Database table posts for model Post was not found. 错误:找不到模型发布的数据库表发布。

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

Whats wrong with the code ? 代码有什么问题?

NB: I needed to use cakephp version 1.3 注意:我需要使用cakephp version 1.3

Error: Database table posts for model Post was not found. 错误:找不到模型发布的数据库表发布。

This error indicates that there is no 'posts' table in your database. 该错误表明数据库中没有“ posts”表。

A couple solutions: 几个解决方案:

  • check your database connection App->config->database.php and make sure that is all correct. 检查您的数据库连接App-> config-> database.php,并确保一切正确。
  • ensure that you have a table in your database called 'posts' 确保数据库中有一个名为“ posts”的表

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

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