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