From: Andrey Kutejko Date: Sat, 17 Aug 2013 08:10:10 +0000 (+0300) Subject: order findAll and findBy* queries X-Git-Tag: 0.5~52 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=5b2c096838d397bef7a0d6c1978a814c4c4958d2;p=ipf.git order findAll and findBy* queries --- diff --git a/ipf/orm/table.php b/ipf/orm/table.php index af2c781..b2708b2 100644 --- a/ipf/orm/table.php +++ b/ipf/orm/table.php @@ -523,7 +523,10 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable public function findAll($hydrationMode = null) { - return $this->createQuery()->execute(array(), $hydrationMode); + $q = $this->createQuery(); + if ($this->_ordering) + $q->orderBy(implode(', ', $this->_ordering)); + return $q->execute(array(), $hydrationMode); } public function findBySql($dql, $params = array(), $hydrationMode = null) @@ -948,7 +951,10 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable protected function findBy($fieldName, $value, $hydrationMode = null) { - return $this->createQuery()->where($fieldName . ' = ?', array($value))->execute(array(), $hydrationMode); + $q = $this->createQuery()->where($fieldName . ' = ?', array($value)); + if ($this->_ordering) + $q->orderBy(implode(', ', $this->_ordering)); + return $q->execute(array(), $hydrationMode); } protected function findOneBy($fieldName, $value, $hydrationMode = null)