您的位置:首页 > 其它

使用Gii生成的CountrySearch不能使用的问题

2016-05-09 08:37 302 查看
When I following the steps in http://www.yiiframework.com/doc-2.0/guide-start-gii.html. try to generate some CRUD operate for country table.

I following the details steps which tutorial told. but when I visit http://localhost/index.php?r=country%2Findex, I got below exception.

The table does not exist: {{%country_search}}

The reason why this exception throws. Because Yii2 assume there exist country_search table in you MySQL, but if you look inside you code, the CountrySearch extends from Country, so it should use the same table as Country class. what you should do to fix this issue. you only need create a tableName method to tell Yii2 which table name need to use.

public static function tableName()
{
return "Country";
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: