diff --git a/cake/libs/model/model_php4.php b/cake/libs/model/model_php4.php index cb81eeb09..56c154c6c 100644 --- a/cake/libs/model/model_php4.php +++ b/cake/libs/model/model_php4.php @@ -240,6 +240,13 @@ class Model extends Object{ */ var $recursive = 1; +/** + * Default ordering of model records + * + * @var mixed + */ + var $order = null; + /** * Default association keys * @@ -1109,17 +1116,22 @@ class Model extends Object{ } if ($order == null) { - $order = array(); + if ($this->order == null) { + $order = array(); + } else { + $order = array($this->order); + } } else { $order = array($order); } - $queryData = array('conditions' => $conditions, - 'fields' => $fields, - 'joins' => array(), - 'limit' => $limit, - 'offset' => $offset, - 'order' => $order + $queryData = array( + 'conditions' => $conditions, + 'fields' => $fields, + 'joins' => array(), + 'limit' => $limit, + 'offset' => $offset, + 'order' => $order ); if (!$this->beforeFind($queryData)) { diff --git a/cake/libs/model/model_php5.php b/cake/libs/model/model_php5.php index 53992bb7e..b60e9f36f 100644 --- a/cake/libs/model/model_php5.php +++ b/cake/libs/model/model_php5.php @@ -240,6 +240,13 @@ class Model extends Object{ */ var $recursive = 1; +/** + * Default ordering of model records + * + * @var mixed + */ + var $order = null; + /** * Default association keys * @@ -1106,17 +1113,22 @@ class Model extends Object{ } if ($order == null) { - $order = array(); + if ($this->order == null) { + $order = array(); + } else { + $order = array($this->order); + } } else { $order = array($order); } - $queryData = array('conditions' => $conditions, - 'fields' => $fields, - 'joins' => array(), - 'limit' => $limit, - 'offset' => $offset, - 'order' => $order + $queryData = array( + 'conditions' => $conditions, + 'fields' => $fields, + 'joins' => array(), + 'limit' => $limit, + 'offset' => $offset, + 'order' => $order ); if (!$this->beforeFind($queryData)) {