我想將查詢結果匯出到分頁。并且分頁每頁應該有以下資料結果,列名,偏移量。
我試過這個代碼
$customer = Customer::where("customer_id", $request->customer_id)->first();
$customer->paginate($request->limit, ['*'], $request->offset)->toArray();
但是這個代碼給我帶來了很多客戶,我不想要這個。它忽略 where 條件。
正如我之前所說,我想分頁應該每頁都有,列名(我現在 ['*'] 是列名),偏移量,當然還有我的查詢結果。
uj5u.com熱心網友回復:
我不認為 first() 和 toArray() 函式在這里沒問題。我會去做這樣的事情:
$customer = Customer::where('customer_id', $request->customer_id)->paginate(
$request->limit, ['*'], $request->offset
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/342611.html
上一篇:mysql-獲取出現次數
