【发布时间】:2015-05-17 14:44:51
【问题描述】:
我在 laravel eloquent 中有以下模型
class InterviewList extends Eloquent{
protected $table = 'interviewlists';
public function subject(){
return $this->belongsTo('Subject','id_subject','id');
}}
class Subject extends Eloquent{
public function interviewList(){
return $this->hasMany('InterviewList');
}}
我需要获取主题名称为“java”的 interviewList 表的 ID, 在主题表中,我有(id,name)列,在 interviewList 表中(id,name,id_subject)。 我试过下面的代码
$interviewListId = InterviewList::with('Subject')->whereName('java')->get(array('id'));
但它只是没有结果
【问题讨论】:
标签: php mysql laravel laravel-4 eloquent