改进where对空条件的判断

This commit is contained in:
thinkphp
2016-04-10 23:12:34 +08:00
parent 522e6cf8bf
commit 32ba255de9

View File

@@ -665,11 +665,12 @@ abstract class Driver
} }
$where = $this->parseWhereExp($field, $op, $condition); $where = $this->parseWhereExp($field, $op, $condition);
if (!empty($where)) {
if (!isset($this->options['where']['AND'])) { if (!isset($this->options['where']['AND'])) {
$this->options['where']['AND'] = []; $this->options['where']['AND'] = [];
}
$this->options['where']['AND'] = array_merge($this->options['where']['AND'], $where);
} }
$this->options['where']['AND'] = array_merge($this->options['where']['AND'], $where);
return $this; return $this;
} }
@@ -684,10 +685,12 @@ abstract class Driver
public function whereOr($field, $op = null, $condition = null) public function whereOr($field, $op = null, $condition = null)
{ {
$where = $this->parseWhereExp($field, $op, $condition); $where = $this->parseWhereExp($field, $op, $condition);
if (!isset($this->options['where']['OR'])) { if (!empty($where)) {
$this->options['where']['OR'] = []; if (!isset($this->options['where']['OR'])) {
$this->options['where']['OR'] = [];
}
$this->options['where']['OR'] = array_merge($this->options['where']['OR'], $where);
} }
$this->options['where']['OR'] = array_merge($this->options['where']['OR'], $where);
return $this; return $this;
} }