custar
unread,Jun 28, 2009, 2:19:09 PM6/28/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to CakePHP-ja
BsC から見れば B, C は親なので、saveAll() が使える。
以下で、未登録な B, C のデータを保存し、そのまま joinTable にも登録できる。
//b.php
public function save($data = null, $validate = true, $fieldList = array
())
{
$this->BsC->bindModel(
array(
'belongsTo' => array(
'B' => array(
'foreignKey' => 'b_id',
'type' => 'INNER',
'conditions' => array('BsC.b_id = B.id')
),
'C' => array(
'foreignKey' => 'c_id',
'type' => 'INNER',
'conditions' => array('BsC.c_id = C.id')
)
)
)
);
return $this->BsC->saveAll($data);
}