【发布时间】:2015-05-01 18:02:28
【问题描述】:
假设我有如下功能(在 Laravel 4.2 中):
public static function getResult($class_id,$section_id,$session,$term,$setTerm = ture)
{
$result = self::with('Student','Student.getClass','Student.getSection')
->where('class_id',$class_id)
->where('section_id',$section_id)
->where('exam_year',$session)
->where('term',$term)
->orderBy('class_roll','ASC')->get();
return $result;
}
因此,如果 $setTerm 设置为 false,则不应执行 (->where('term',$term))。
在查询构建期间如何在 Laravel 中执行条件操作?
谢谢
【问题讨论】:
标签: php mysql laravel laravel-4 laravel-5