Php Laravel DB mysql选择列在数组中的位置?
我将一个数组发送到我在Laravel 5中制作的API,这是一个允许值的数组,例如:Php Laravel DB mysql选择列在数组中的位置?,php,mysql,arrays,laravel,laravel-5,Php,Mysql,Arrays,Laravel,Laravel 5,我将一个数组发送到我在Laravel 5中制作的API,这是一个允许值的数组,例如:[1,3,5] 我尝试这样选择: $json = (object)Input::all(); $loans = DB::table("loans") ->where("years", ">=", $json->year_low) ->where("years", "<=", $json->year_high) ->w
[1,3,5]
我尝试这样选择:
$json = (object)Input::all();
$loans = DB::table("loans")
->where("years", ">=", $json->year_low)
->where("years", "<=", $json->year_high)
->where("risk", $json->risks)
->get();
$json=(对象)输入::all();
$LOANTS=DB::表格(“贷款”)
->其中(“年数”,“>=”,$json->year\u low)
->其中,“年”,如果您的意思是$json->risks
类似于数组[1,2,3]
,请尝试以下操作
->whereIn("risk", $json->risks)
我对您的脚本做了一些更改:
$json = (object)Input::all();
$loans = DB::table("loans")
->where("years", ">=", $json->year_low)
->where("years", "<=", $json->year_high)
->whereIn("risk", array($json->risks))
->get();
$json=(对象)输入::all();
$LOANTS=DB::表格(“贷款”)
->其中(“年数”,“>=”,$json->year\u low)
->where(“年”,where()
也许?