1
表:graduate_applicants
CREATE TABLE IF NOT EXISTS `graduate_applicants` (
`grat_id` int(10) NOT NULL auto_increment,
`studentnum` int(9) NOT NULL,
`QuarterID` int(10) NOT NULL,
PRIMARY KEY (`grat_id`)
)
表:stu_students
CREATE TABLE IF NOT EXISTS `stu_students` (
`id` int(11) NOT NULL auto_increment,
`studentid` int(9) default NULL,
`firstname` varchar(50) default NULL,
`lastname` varchar(50) default NULL,
`email` varchar(100) default NULL,
PRIMARY KEY (`id`),
KEY `studentid` (`studentid`),
)
型號:
class GraduateApplicant extends AppModel{
var $name = 'GraduateApplicant';
var $tablePrefix = '';
var $belongsTo = array('Student' => array('className' => 'Student','foreignKey' => false,''conditions' => array('Student.studentid=GraduateApplicant.studentnum'),'fields' => '','order' => ''),);
}
控制器:
$list = $this->paginate('GraduateApplicant');
我不明白爲什麼$ list是空的?
您是將它包含在'contains'還是''recursive''中?此外,您的示例模型在'條件'之前的'$ belongsTo'定義中有額外的引號。最後,顯示你的SQL。 – jeremyharris
爲什麼字段設置爲''? –
你可以發佈你的學生模型嗎? –