改进parseOrder对rand的支持

This commit is contained in:
thinkphp
2017-01-20 20:27:55 +08:00
parent 069d63a2fc
commit 249c5e62e4

View File

@@ -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 : '';