From ae442796ebf461f6dcdcad631ea0691913a842a8 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 12 Apr 2018 16:31:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 4 ++++ library/think/db/builder/Sqlsrv.php | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 3dfccab4..e4066c68 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -563,6 +563,10 @@ abstract class Builder */ protected function parseOrder($order, $options = []) { + if (empty($order)) { + return ''; + } + $array = []; foreach ($order as $key => $val) { if ($val instanceof Expression) { diff --git a/library/think/db/builder/Sqlsrv.php b/library/think/db/builder/Sqlsrv.php index 6207518e..ed961491 100644 --- a/library/think/db/builder/Sqlsrv.php +++ b/library/think/db/builder/Sqlsrv.php @@ -35,6 +35,9 @@ class Sqlsrv extends Builder */ protected function parseOrder($order, $options = []) { + if (empty($order)) { + return ' ORDER BY rand()'; + } $array = []; foreach ($order as $key => $val) { @@ -55,7 +58,7 @@ class Sqlsrv extends Builder } $order = implode(',', $array); - return !empty($order) ? ' ORDER BY ' . $order : ' ORDER BY rand()'; + return ' ORDER BY ' . $order; } /**