我有一个 asset_request
表,其中包含字段 id
和 request_id
。
我想选择具有特定 ID 的多行。
$ids = $request->ids//5,6
我只想选择请求表中 id 为 5 和 6 的行
$ids = $request->ids;
$asset_request = asset_request::whereIn('id',array($ids))->first(); //gets only 6th row.
我需要获取与给定 ID 匹配的所有行。
最佳答案
在与 Op 聊天讨论后澄清:
Op 正在传回字符串请求,因此,Op 需要更改以下内容:
$id = $request->id;
$ids = str_split(str_replace(',', '', $id));
$asset_request = asset_request::whereIn('id', $ids)->get();
关于laravel - 获取具有多个 id 的单个查询中的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49747971/