我有2个模型:
Mail
有关系的类:
'relAttachments' => array(self::MANY_MANY, 'File', 'rel_mail_file(rel_mail, rel_file)'),
Mail
附加了AdvancedArBehavior扩展,因此我可以使用 1-liner 将附件链接到它,我喜欢这样:
$mail->relAttachments = $attachments; // $attachments is an array of ids for `File` models
Mailque
有关系的类:
'relMail' => array(self::BELONGS_TO, 'Mail', 'rel_mail'),
保存并链接 Mail 和 Mailque 后,我在发送邮件后运行此代码:
$mail = Mail::model()->findByPk($id);
$mailModel = $mail->relMail;
var_dump(count($mailModel->relAttachments)); // outputs 1
$mailModel->sent = time();
$mailModel->save();
//$mail->delete();
调用 save() 会产生以下错误:
exception 'CException' with message 'Property "File.rel_file" is not defined.' in ...\framework\base\CComponent.php:131
有谁知道这里发生了什么?