标签 - Thinkphp

Thinkphp    2020-09-11 13:36:23    42    0    0

找到 service\tp5\thinkphp\library\think\db\Builder.php 中 order分析

修改为下面这样的

  1. protected function parseOrder($order, $options = [])
  2. {
  3. if (is_array($order)) {
  4. $array = [];
  5. foreach ($order as $key => $val) {
  6. if (is_numeric($key)) {
  7. if ('[rand]' == $val) {
  8. if (method_exists($this, 'parseRand')) {
  9. $array[] = $this->parseRand();
  10. } else {
  11. throw new BadMethodCallException('method not exists:' . get_class($this) . '-> parseRand');
  12. }
  13. } elseif (false === strpos($val, '(')) {
  14. $array[] = $this->parseKey($val, $options);
  15. } else {
  16. $array[] = $val;
  17. }
  18. } else {
  19. $sort = in_array(strtolower(trim($val)), ['asc', 'desc']) ? ' ' . $