Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Nov 17, 2016
2 parents c0c843b + 04548b8 commit d26ddc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Builder
// 最后插入ID
protected $insertId = [];
// 查询表达式
protected $exp = ['<>' => 'ne', 'neq' => 'ne', '=' => '=', '>' => 'gt', '>=' => 'gte', '<' => 'lt', '<=' => 'lte', 'in' => 'in', 'not in' => 'nin', 'nin' => 'nin', 'mod' => 'mod', 'exists' => 'exists', 'regex' => 'regex', 'type' => 'type', 'all' => 'all', '> time' => '> time', '< time' => '< time', 'between' => 'between', 'not between' => 'not between', 'between time' => 'between time', 'not between time' => 'not between time', 'notbetween time' => 'not between time', 'like' => 'like'];
protected $exp = ['<>' => 'ne', 'neq' => 'ne', '=' => 'eq', '>' => 'gt', '>=' => 'gte', '<' => 'lt', '<=' => 'lte', 'in' => 'in', 'not in' => 'nin', 'nin' => 'nin', 'mod' => 'mod', 'exists' => 'exists', 'regex' => 'regex', 'type' => 'type', 'all' => 'all', '> time' => '> time', '< time' => '< time', 'between' => 'between', 'not between' => 'not between', 'between time' => 'between time', 'not between time' => 'not between time', 'notbetween time' => 'not between time', 'like' => 'like', 'near' => 'near'];

/**
* 架构函数
Expand Down Expand Up @@ -91,7 +91,9 @@ protected function parseData($data, $options)
$result = [];
foreach ($data as $key => $val) {
$item = $this->parseKey($key);
if (isset($val[0]) && 'exp' == $val[0]) {
if (is_object($val)) {
$result[$item] = $val;
} elseif (isset($val[0]) && 'exp' == $val[0]) {
$result[$item] = $val[1];
} elseif (is_null($val)) {
$result[$item] = 'NULL';
Expand Down Expand Up @@ -259,6 +261,9 @@ protected function parseWhereItem($field, $val)
// 范围查询
$value = is_array($value) ? $value : explode(',', $value);
$query[$key] = ['$lt' => $this->parseDateTime($value[0], $field), '$gt' => $this->parseDateTime($value[1], $field)];
} elseif ('near' == $exp) {
// 经纬度查询
$query[$key] = ['$near' => $this->parseValue($value, $key)];
} else {
// 普通查询
$query[$key] = $this->parseValue($value, $key);
Expand Down
2 changes: 1 addition & 1 deletion src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ public function maxTimeMS($maxTimeMS)
public function field($field, $except = false)
{
if (is_string($field)) {
$field = explode(',', $field);
$field = array_map('trim', explode(',', $field));
}
$projection = [];
foreach ($field as $key => $val) {
Expand Down

0 comments on commit d26ddc4

Please sign in to comment.