我正在尝试在Laravel中执行以下查询,但是在编写DB类和Eloquent类时遇到了麻烦。 我想做类似以下的事情..
$week = DB::select('SELECT week FROM calendar WHERE year = 2015 and month = 01 and day = 30');
$secondResult = DB::select("SELECT * FROM calendar WHERE year = 2015 and week = $week");
return View::make('calendar')->with('weekdays',$secondResult);
答案 0 :(得分:1)
试试这个..
$week = DB::select('SELECT week FROM calendar WHERE year = 2015 and month = 01 and day = 30');
foreach ($week as $weekvalue)
{
echo $weekname=$weekvalue->week;
}
$secondResult = DB::select("SELECT * FROM calendar WHERE year = 2015 and week = $weekname");
return View::make('calendar')->with('weekdays',$secondResult);