search

Home  >  Q&A  >  body text

laravel orderBy problem?

Laravel's orderBy('a','desc'), if I still want to sort b in descending order under the same situation as a, how should I write it

PHPzPHPz2869 days ago624

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-05-16 16:57:12

    Write orderBy('b','desc') directly at the end;
    You can use the ->toSql() method to view the executed sql statement for easy debugging.

    reply
    0
  • PHPz

    PHPz2017-05-16 16:57:12

    ->orderBy('a','desc')->orderBy('b','desc')
    //可以自己输出下sql看看
    DB::connection()->enableQueryLog();
    var_dump(DB::getQueryLog());

    reply
    0
  • Cancelreply