Browse Source

update orderBy method

Jinhui Zhu 7 năm trước cách đây
mục cha
commit
e70a66a0da
1 tập tin đã thay đổi với 21 bổ sung2 xóa
  1. 21 2
      Qii/Driver/Base.php

+ 21 - 2
Qii/Driver/Base.php

@@ -560,10 +560,29 @@ class Base
 	 */
 	final function orderBy($field, $orderBy)
 	{
-		$this->orderBy = null;
-		if (!empty($field)) {
+		if(!empty($field)) return $this;
+
+		if($this->orderBy != '') {
+			$this->orderBy .= $field .' '. $orderBy;
+		}else{
 			$this->orderBy = sprintf($this->_query['ORDER'], $field, $orderBy);
 		}
+	}
+	
+	final function orderByArr($map)
+	{
+		if(empty($map)) return $this;
+		foreach($map AS $val)
+		{
+			$this->orderBy($val['field'], $val['orderBy']);
+		}
+		return $this;
+	}
+
+	final function orderByStr($orderBy)
+	{
+		if(!$orderBy) return $this;
+		$this->orderBy = $orderBy;
 		return $this;
 	}