Re: direction in dataObjects->orderBy()

From: Date: Fri, 14 Feb 2003 11:40:19 +0000
Subject: Re: direction in dataObjects->orderBy()
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-3760@lists.php.net to get a copy of this message
Not sure it will work like that imagine $object->orderBy('abc','desc'); $object->orderBy('xyz','asc'); $object->find(); normally i just do $object->orderBy('abc desc'); perhaps I missed something, but is there really any benifit to adding this rather than just doing? $object->orderBy($col . ' ' . $direction); Regards Alan Till Dawn wrote:
Hy everybody! I'm currently working with dataObjects and there is no possibility to define the direction of the order-statement. So I decided to patch the orderBy-function and the find-function to fit my needs. So that my current version looks like this: ########## ..... var _order_direction = ""; ..... function orderBy( $order = false,$direction = '' ) { // perhaps it can also be set to DESC on default
    $this -> _order_direction = $direction;
    if ( $order == false ) {
        $this -> _order_by = '';
        return;
    }
    if ( !$this -> _order_by ) {
        $this -> _order_by = " ORDER BY {$order} ";
        return;
    }
    $this -> _order_by .= " , {$order}";
} ..... function find( $n = false ) {
    ####snip#####
    $this -> _query( "SELECT " . $this -> _data_select . " FROM " . $this ->
__table . " " . $this -> _join . $this -> _condition . " " . $this -> _group_by . " " . $this -> _order_by . $this -> _order_direction . " " . $this -> _limit ); // I just added $this -> _order_direction after $this -> _order_by
    ####snap#####
} ################## Is this a practicable way? Till Dawn


« previous php.pear.general (#3760) next »