developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #1418: jDaoFactoryBase.findBy.patch

File jDaoFactoryBase.findBy.patch, 1.8 KB (added by Vincentv, 9 years ago)
  • jelix/dao/jDaoConditions.class.php

     
    116116    }
    117117
    118118    /**
     119    * Tells if an order has been set
     120    * @return boolean true is an order was set, false otherwise
     121    */
     122    function hasOrder (){
     123        return (count ($this->order) ? true : false);
     124    }
     125
     126    /**
    119127    * says if there are no conditions
    120128    * @return boolean  false if there isn't condition
    121129    * @since 1.0
  • jelix/dao/jDaoFactoryBase.class.php

     
    244244     * return all record corresponding to the conditions stored into the
    245245     * jDaoConditions object.
    246246     * you can limit the number of results by given an offset and a count
     247     * the order defaults to the ascending primary key(s), if any
    247248     * @param jDaoConditions $searchcond
    248249     * @param int $limitOffset
    249250     * @param int $limitCount
     
    251252     */
    252253    final public function findBy ($searchcond, $limitOffset=0, $limitCount=null){
    253254        $query = $this->_selectClause.$this->_fromClause.$this->_whereClause;
     255        // Force a default order to the primary key(s)
     256        if (!$searchcond->hasOrder()){
     257            foreach ($this->getPrimaryKeyNames() as $pk){
     258                $searchcond->addItemOrder($pk, 'asc');
     259            }
     260        }
    254261        if ($searchcond->hasConditions ()){
    255262            $query .= ($this->_whereClause !='' ? ' AND ' : ' WHERE ');
    256263            $query .= $this->_createConditionsClause($searchcond);