Cakephp HABTM 关系
我有这些桌子 文章 , 文章_货币, 数据库中的货币 我在文章和货币之间创建了 HABTM,如下所示,
var $hasAndBelongsToMany = array('currency'=>array('className' => 'currency','joinTable'=>'article_currency','foreignKey' => 'articleid','associationForeignKey' => 'CurrencyID'));
var $hasAndBelongsToMany = array('articlemodel'=>array('className' => 'articlemodel','joinTable'=>'article_currency','foreignKey' => 'CurrencyID','associationForeignKey' => 'ArticleID'));
这里的蛋糕为我生成了模型 ArticleCurrency 当我尝试使用 with 将其名称更改为“article_currency”时 是给我这个错误 未找到模型article_currency的数据库表article_currencies。
我该如何解决这个问题
i have theses tables
article , article_currency, currency in database
and i made HABTM between article and currency like this
var $hasAndBelongsToMany = array('currency'=>array('className' => 'currency','joinTable'=>'article_currency','foreignKey' => 'articleid','associationForeignKey' => 'CurrencyID'));
var $hasAndBelongsToMany = array('articlemodel'=>array('className' => 'articlemodel','joinTable'=>'article_currency','foreignKey' => 'CurrencyID','associationForeignKey' => 'ArticleID'));
and here cake genrate the model ArticleCurrency for me
when i try to change its name using with to 'article_currency'
is give me this error
Database table article_currencies for model article_currency was not found.
how i can solve this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
按照惯例,表名称为复数:articles、currency、articles_currencies
http:// book.cakephp.org/view/24/Model-and-Database-Conventions
Table names are plural by convention: articles, currencies, articles_currencies
http://book.cakephp.org/view/24/Model-and-Database-Conventions