Skip to content

Commit 3f88130

Browse files
committed
增加whereOr动态查询和unionAll方法
1 parent cf20a9f commit 3f88130

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/db/Query.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ public function __call($method, $args)
112112
// 根据某个字段获取记录的某个值
113113
$name = Db::parseName(substr($method, 10));
114114
return $this->where($name, '=', $args[0])->value($args[1]);
115+
} elseif (strtolower(substr($method, 0, 7)) == 'whereor') {
116+
$name = Loader::parseName(substr($method, 7));
117+
array_unshift($args, $name);
118+
return call_user_func_array([$this, 'whereOr'], $args);
115119
} elseif (strtolower(substr($method, 0, 5)) == 'where') {
116120
$name = Db::parseName(substr($method, 5));
117121
array_unshift($args, $name);
@@ -727,6 +731,17 @@ public function union($union, $all = false)
727731
return $this;
728732
}
729733

734+
/**
735+
* 查询SQL组装 union all
736+
* @access public
737+
* @param mixed $union
738+
* @return $this
739+
*/
740+
public function unionAll($union)
741+
{
742+
return $this->union($union, true);
743+
}
744+
730745
/**
731746
* 指定查询字段 支持字段排除和指定数据表
732747
* @access public

0 commit comments

Comments
 (0)