我有以下 SQL
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
我已经得出以下内容,这几乎是许多示例的副本,但是我在 'field list' 中得到了 1054 Unknown column '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'),
);
我究竟做错了什么?非常感谢