From 249c5e62e475dc87ecfc7a943d3a921c2b4837e5 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 20 Jan 2017 20:27:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BparseOrder=E5=AF=B9rand?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 3e7a60e9..b9683969 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -523,10 +523,12 @@ abstract class Builder $array = []; foreach ($order as $key => $val) { if (is_numeric($key)) { - if (false === strpos($val, '(')) { - $array[] = $this->parseKey($val, $options); - } elseif ('[rand]' == $val) { + if ('[rand]' == $val) { $array[] = $this->parseRand(); + } elseif (false === strpos($val, '(')) { + $array[] = $this->parseKey($val, $options); + } else { + $array[] = $val; } } else { $sort = in_array(strtolower(trim($val)), ['asc', 'desc']) ? ' ' . $val : '';