#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    43
    Rep Power
    4

    PHP query order by?


    Hello

    I have this code and now the table order by ASC
    i wanted to order by (by default DESC)

    private function _buildOrder($order){
    $orderBy='';
    if(is_array($order)){
    foreach($order as $field=>$seq){
    if(in_array(strtoupper($seq),array('ASC','DESC'))){
    $orderBy=' ORDER BY '.$this->_esStr($field).' '.$this->_esStr($seq);
    break;
    }
    }
    }
    return $orderBy;
    }




    thanks
  2. #2
  3. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,112
    Rep Power
    487
    Then add "DESC" to the ORDER BY bit
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984

IMN logo majestic logo threadwatch logo seochat tools logo