我有以下SQLCdbcriteria加入 - 列未找到
SELECT entry_subject.id, entry_subject.subject_id FROM entry_subject INNER JOIN subject ON entry_subject.subject_id = subject.id WHERE subject.id = 71
我已經到達了它是一個數字的例子幾乎翻版以下,但是我得到1054未知列'字段列表'中的'EntrySubject.subject_id'。
$subjectEntries = new CDbCriteria();
$subjectEntries->alias = 'EntrySubject';
$subjectEntries->select = 'EntrySubject.id, EntrySubject.subject_id';
$subjectEntries->join = 'INNER JOIN Subject ON Subject.id = EntrySubject.subject_id';
$subjectEntries->condition = 'Subject.id=71';
$subjectEntriesModel=Subject::model()->findAll($subjectEntries);
我的關係如下
return array(
'entrySubject' => array(self::HAS_MANY, 'EntrySubject', 'subject_id'),
'phase' => array(self::BELONGS_TO, 'Phase', 'phase_id'),
'subjectType' => array(self::BELONGS_TO, 'SubjectType', 'subject_type'),
);
我在做什麼錯? 非常感謝
,您在一個「主題」模式選擇「EntrySubject.id,EntrySubject.subject_id」 ... –