Skip to content

Commit

Permalink
增加whereOr动态查询和unionAll方法
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Dec 4, 2017
1 parent cf20a9f commit 3f88130
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ public function __call($method, $args)
// 根据某个字段获取记录的某个值
$name = Db::parseName(substr($method, 10));
return $this->where($name, '=', $args[0])->value($args[1]);
} elseif (strtolower(substr($method, 0, 7)) == 'whereor') {
$name = Loader::parseName(substr($method, 7));
array_unshift($args, $name);
return call_user_func_array([$this, 'whereOr'], $args);
} elseif (strtolower(substr($method, 0, 5)) == 'where') {
$name = Db::parseName(substr($method, 5));
array_unshift($args, $name);
Expand Down Expand Up @@ -727,6 +731,17 @@ public function union($union, $all = false)
return $this;
}

/**
* 查询SQL组装 union all
* @access public
* @param mixed $union
* @return $this
*/
public function unionAll($union)
{
return $this->union($union, true);
}

/**
* 指定查询字段 支持字段排除和指定数据表
* @access public
Expand Down

0 comments on commit 3f88130

Please sign in to comment.