【发布时间】:2020-04-04 19:22:35
【问题描述】:
我正在 Laravel 中为移动应用程序创建 API。我面临一个问题,我必须将两个数组作为 json 传递,但它显示错误。这是我正在使用的代码
public function showSearchPage($subCatId)
{
$allAdQuery=DB::select('select * from addata where
fk_adData_subCatData_id=:subId order by adData_date desc, adData_time desc',
["subId"=>$subCatId]);
$allProductQuery=DB::select('select sellerProductData_title, sellerProductData_price,
fk_sellerProductData_subCatData_id,sellerProductData_id from
sellerproductdata where fk_sellerProductData_subCatData_id=:subId
order by sellerProductData_date desc',["subId"=>$subCatId]);
return \Response::json($allAdQuery,$allAdQuery);
}
它告诉我这个错误
Symfony\Component\Debug\Exception\FatalThrowableError (E_RECOVERABLE_ERROR) 参数 2 传递给 Symfony\Component\HttpFoundation\JsonResponse::__construct() 必须是 整数类型,给定数组,在
中调用
知道如何传递两个或多个数组吗?谢谢
【问题讨论】:
-
\Response::json([$allAdQuery,$allAdQuery]);? -
@u_mulder 感谢它的工作。为什么不将其发布为答案,以便我可以标记它:)