【发布时间】:2009-07-23 07:17:29
【问题描述】:
可能是一个新手问题,因为我想在空闲时间看看所有这些“PHP 框架”是什么。
对于初学者,我想为多张照片添加多个标签。我有一个标签模型和 mot 模型(照片)。 mot模型截图:
var $hasAndBelongsToMany = array(
'Tag' =>
array(
'className' => 'Tag',
'joinTable' => 'mots_tags',
'foreignKey' => 'mot_id',
'associationForeignKey' => 'tag_id',
'unique' => false
)
);
在 add() 的标签控制器中,我有:
$this->Tag->save($this->data);
当 print_r'ing $this->data 我看到:
Array
( [Mot] => 数组 ( [id] => 2 )
[Tag] => Array
(
[title] => 21e21e
)
)
标签被插入到标签表中,但是没有任何东西被插入到 mottags(在 mot 和 tag 之间有下划线,但是当我在这里写它而不是变成下划线时它是斜体)表。我的 mots_tags 数据库架构:(sqlite)
create table mots_tags (id INTEGER PRIMARY KEY, mot_id INTEGER, tag_id INTEGER)
Cake 只写入 Tags 表而不写入 associacions 表的任何线索?我没有收到任何 SQL 错误。有没有办法查看它是否尝试写入关联表?
【问题讨论】:
标签: cakephp has-and-belongs-to-many