mirror of https://gitee.com/karson/fastadmin.git
!260 修复selectpage自定义 data-primary-key 为非数值型内容导致自定义排序SQL报错BUG
Merge pull request !260 from 傲杰笔记/fix_bugpull/260/MERGE
commit
662d211946
|
|
@ -539,6 +539,11 @@ class Backend extends Controller
|
|||
//如果有primaryvalue,说明当前是初始化传值,按照选择顺序排序
|
||||
if ($primaryvalue !== null && preg_match("/^[a-z0-9_\-]+$/i", $primarykey)) {
|
||||
$primaryvalue = array_unique(is_array($primaryvalue) ? $primaryvalue : explode(',', $primaryvalue));
|
||||
//修复自定义data-primary-key为字符串内容时,给排序字段添加上引号
|
||||
$primaryvalue= array_map(function ($value) {
|
||||
return '\'' . $value . '\'';
|
||||
}, $primaryvalue);
|
||||
|
||||
$primaryvalue = implode(',', $primaryvalue);
|
||||
|
||||
$this->model->orderRaw("FIELD(`{$primarykey}`, {$primaryvalue})");
|
||||
|
|
|
|||
Loading…
Reference in New Issue