作者 liyuhang

gx

@@ -24,7 +24,7 @@ class Base extends Model @@ -24,7 +24,7 @@ class Base extends Model
24 */ 24 */
25 public function lists($map, $p, $row, $order = 'id', $fields = ['*']){ 25 public function lists($map, $p, $row, $order = 'id', $fields = ['*']){
26 //TODO::where(['id'=>'','name'=>'']) 26 //TODO::where(['id'=>'','name'=>''])
27 - $lists = $this->select($fields)->wheres($map)->orderBy($order)->paginate($row, ['*'], 'page', $p); 27 + $lists = $this->select($fields)->where($map)->orderBy($order)->paginate($row, ['*'], 'page', $p);
28 if (empty($lists)) { 28 if (empty($lists)) {
29 return false; 29 return false;
30 } 30 }
@@ -43,7 +43,7 @@ class Base extends Model @@ -43,7 +43,7 @@ class Base extends Model
43 * @method 43 * @method
44 */ 44 */
45 public function list($map,$order = 'id',$fields = ['*']){ 45 public function list($map,$order = 'id',$fields = ['*']){
46 - $lists = $this->select($fields)->wheres($map)->orderBy($order)->get(); 46 + $lists = $this->select($fields)->where($map)->orderBy($order)->get();
47 if (empty($lists)) { 47 if (empty($lists)) {
48 return false; 48 return false;
49 } 49 }
@@ -59,7 +59,8 @@ class Base extends Model @@ -59,7 +59,8 @@ class Base extends Model
59 */ 59 */
60 public function read($condition,$files = ['*']) 60 public function read($condition,$files = ['*'])
61 { 61 {
62 - $info = $this->select($files)->wheres($condition)->first(); 62 + $query = formatQuery($condition);
  63 + $info = $query->select($files)->where($condition)->first();
63 if (empty($info)) { 64 if (empty($info)) {
64 return false; 65 return false;
65 } 66 }
@@ -88,7 +89,7 @@ class Base extends Model @@ -88,7 +89,7 @@ class Base extends Model
88 */ 89 */
89 public function edit($data,$condition){ 90 public function edit($data,$condition){
90 $data['updated_at'] = date('Y-m-d H:i:s'); 91 $data['updated_at'] = date('Y-m-d H:i:s');
91 - return $this->wheres($condition)->update($data); 92 + return $this->where($condition)->update($data);
92 } 93 }
93 94
94 /** 95 /**
@@ -98,11 +99,11 @@ class Base extends Model @@ -98,11 +99,11 @@ class Base extends Model
98 * @method 99 * @method
99 */ 100 */
100 public function del($condition){ 101 public function del($condition){
101 - return $this->wheres($condition)->delete(); 102 + return $this->where($condition)->delete();
102 } 103 }
103 104
104 105
105 - public function wheres($map,$val = ''){ 106 + public function formatQuery($map,$val = ''){
106 $query = $this; 107 $query = $this;
107 $query->where(function ($query) use ($map,$val){ 108 $query->where(function ($query) use ($map,$val){
108 //拼接数据 109 //拼接数据