From 5b2c096838d397bef7a0d6c1978a814c4c4958d2 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sat, 17 Aug 2013 11:10:10 +0300 Subject: [PATCH] order findAll and findBy* queries --- ipf/orm/table.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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) -- 2.49.0