mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
增加随机排序支持
This commit is contained in:
@@ -107,4 +107,14 @@ class Mysql extends Driver
|
||||
return $key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 随机排序
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function parseRand()
|
||||
{
|
||||
return 'rand()';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,4 +189,14 @@ class Oracle extends Driver
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机排序
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function parseRand()
|
||||
{
|
||||
return 'DBMS_RANDOM.value';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,4 +110,14 @@ class Pgsql extends Driver
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机排序
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function parseRand()
|
||||
{
|
||||
return 'RANDOM()';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,4 +91,14 @@ class Sqlite extends Driver
|
||||
}
|
||||
return $limitStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机排序
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function parseRand()
|
||||
{
|
||||
return 'RANDOM()';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,24 +93,13 @@ class Sqlsrv extends Driver
|
||||
}
|
||||
|
||||
/**
|
||||
* order分析
|
||||
* 随机排序
|
||||
* @access protected
|
||||
* @param mixed $order
|
||||
* @return string
|
||||
*/
|
||||
protected function parseOrder($order)
|
||||
protected function parseRand()
|
||||
{
|
||||
$array = [];
|
||||
foreach ($order as $key => $val) {
|
||||
if (is_numeric($key)) {
|
||||
$array[] = $this->parseKey($val);
|
||||
} else {
|
||||
$sort = in_array(strtolower(trim($val)), ['asc', 'desc']) ? ' ' . $val : '';
|
||||
$array[] = $this->parseKey($key) . ' ' . $sort;
|
||||
}
|
||||
}
|
||||
$order = implode(',', $array);
|
||||
return !empty($order) ? ' ORDER BY ' . $order : ' ORDER BY rand()';
|
||||
return 'rand()';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user