简体   繁体   English

Laravel-从表中全部选择SELECT的结果

[英]Laravel - SELECT all from table with the result from previous SELECT

I'm trying to perform the following query in Laravel but have had trouble working out the DB class and Eloquent classes. 我正在尝试在Laravel中执行以下查询,但在计算DB类和Eloquent类时遇到了麻烦。 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM