I'm trying to perform the following query in Laravel but have had trouble working out the DB class and Eloquent classes. I would like to do something like the following..
$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);
Try this..
$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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.