【发布时间】:2021-04-14 13:13:11
【问题描述】:
if (!Cache::store('file')->has('channel')) {
$products = Channel::select('*');
Cache::store('redis')->put('channel', $products, 86400);
}
$products = Cache::store('redis')->get('channel', []);
return DataTables::eloquent($products)
->addIndexColumn()
->make(true);
如果我正在尝试,这会抛出“不允许序列化 'PDO'”
if (!Cache::store('file')->has('channel')) {
$products = Channel::select('*')->get();
Cache::store('redis')->put('channel', $products, 86400);
}
$products = Cache::store('redis')->get('channel', []);
return DataTables::eloquent($products)
->addIndexColumn()
->make(true);
然后数据表抛出 Method Illuminate\Database\Eloquent\Collection::getQuery 不存在的错误
谁有解决办法?
【问题讨论】:
-
使用第二个选项,因为您不能序列化查询对象。如果您没有传递 Eloquent 集合,请不要使用
eloquent()方法。只需使用of()并让Datatables类找出你传递的内容。 -
是的,谢谢。
标签: php mysql laravel redis predis