cakephp在数据源默认中找不到模型的表 [英] cakephp Table for model was not found in datasource default
本文介绍了cakephp在数据源默认中找不到模型的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只有一个表在我的数据库命名为ficha_seg。
我的模型文件的名称是Ficha.php,控制器的名称是FichasController.php。
I have just a table on my database named "ficha_seg". The name of my model file is "Ficha.php" and the name of the controller is "FichasController.php".
获取错误:
Error: Table fichas for model Ficha was not found in datasource default.
:
public function index() {
$this->set('ficha_seg', $this->Ficha->find('all'));
}
推荐答案
如果你需要为你的模型使用另一个表名,你可以使用 useTable
属性:
If you need to use another table name for your model, you can use the useTable
attribute:
class Ficha extends AppModel
{
public $useTable = 'ficha_seg';
}
查看 http://book.cakephp.org/2.0/en/models/model-attributes.html#usetable
和模型约定
这篇关于cakephp在数据源默认中找不到模型的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文