]> git.andy128k.dev Git - ipf.git/commitdiff
order findAll and findBy* queries
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 17 Aug 2013 08:10:10 +0000 (11:10 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 17 Aug 2013 08:10:10 +0000 (11:10 +0300)
ipf/orm/table.php

index af2c781db73e9437d6f1aa155bc6dcd6724575dc..b2708b245cd76859bc24f50bbb01b5375c8e39e1 100644 (file)
@@ -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)