查询日期或者时间
@access public
@param string       $field 日期字段名
@param string       $op    比较运算符或者表达式
@param string|array $range 比较范围
@return $this
324935
public function whereTime($field, $op, $range = null)
    {
        if (is_null($range)) {
            // 使用日期表达式
            $date = getdate();
            switch (strtolower($op)) {
                case 'today':
                case 'd':
                    $range = ['today', 'tomorrow'];
                    break;
                case 'week':
                case 'w':
                    $range = 'this week 00:00:00';
                    break;
                case 'month':
                case 'm':
                    $range = mktime(0, 0, 0, $date['mon'], 1, $date['year']);
                    break;
                case 'year':
                case 'y':
                    $range = mktime(0, 0, 0, 1, 1, $date['year']);
                    break;
                case 'yesterday':
                    $range = ['yesterday', 'today'];
                    break;
                case 'last week':
                    $range = ['last week 00:00:00', 'this week 00:00:00'];
                    break;
                case 'last month':
                    $range = [date('y-m-01', strtotime('-1 month')), mktime(0, 0, 0, $date['mon'], 1, $date['year'])];
                    break;
                case 'last year':
                    $range = [mktime(0, 0, 0, 1, 1, $date['year'] - 1), mktime(0, 0, 0, 1, 1, $date['year'])];
                    break;
                default:
                    $range = $op;
            }
            $op = is_array($range) ? 'between' : '>';
        }
        $this->where($field, strtolower($op) . ' time', $range);
        return $this;
    }
1195276
public function where($field, $operator = null, $value = null) {
        if (strlen($field) && is_null($operator) && is_null($value)) {
            // For RAW string
            array_push($this->_where, $field);
        } else {
            if (is_null($value)) {
                $value = $operator;
                $operator = '=';
            }

            if (is_array($value)) {
                $str = '(';
                
                for ($i = 0; $i < count($value); $i++) {
                    $d = $value[$i];
                    $str .= is_numeric($d) ? $d : "'$d'";
                    $str .= count($value) === $i + 1 ? '' : ', ';
                }
                
                $str .= ')';
                
                $value = $str;
                
                array_push($this->_where, $field . ' ' . $operator . $value);
            } else {
                $value = (string)$value;
                array_push($this->_where, $field . ' ' . $operator . (!strcasecmp($operator, 'in') ? " ($value)" : ' \'' . $value . '\''));
            }
        }
        
        return $this;
    }
1188851
public static Query withValue(String field,
                                  BinOp op,
                                  Literal value) {
        Query q = new Query(false);
        q.add("field", field).add("op", op.toString()).add("rvalue", value.toJson());
        return q;
    }
144131
public function condition($field, $value = NULL, $expressionOperator = NULL)
    {

        if (!isset($expressionOperator)) {
            if (is_array($value)) {
                $expressionOperator = 'IN';
            }
            else {
                $expressionOperator = '=';
            }
        }
        $this->conditions[] = array(
            'field' => $field,
            'value' => $value,
            'operator' => $expressionOperator,
        );
        return $this;
    }
91297
private function createCreaseFields(array $fields, string $op, float $diff): array
    {
        $diff = floatval($diff);

        $sqlArray = $prepares = $params = [];

        foreach ($fields as $field) {
            // 对字段名进行规范化
            $f = $this->db->markField($field);

            // 用于SQL中
            $sqlArray[] = $this->db->createCrease($f, $op, $diff);

            // 用于Prepare中
            $prepares[] = $this->db->createCrease($f, $op, '?');

            // 用于Params中
            $params[] = $diff;
        }

        return [$sqlArray, $prepares, $params];
    }
834001
public function and_where($column, $op = null, $value = null)
	{
		if($column instanceof \Closure)
		{
			$this->and_where_open();
			$column($this);
			$this->and_where_close();
			return $this;
		}

		if (is_array($column))
		{
			foreach ($column as $key => $val)
			{
				if (is_array($val))
				{
					$this->and_where($val[0], $val[1], $val[2]);
				}
				else
				{
					$this->and_where($key, '=', $val);
				}
			}
		}
		else
		{
			if(func_num_args() === 2)
			{
				$value = $op;
				$op = '=';
			}
			$this->_where[] = array('AND' => array($column, $op, $value));
		}

		return $this;
	}
817752
public function whereExp($field, $condition, $logic = 'and')
    {
        $this->parseWhereExp($logic, $field, 'exp', $condition);
        return $this;
    }
109678
public function whereBetween($field, array $params, string $op = ''): self
    {
        return $this->where($this->prepareField($field) .' BETWEEN ? AND ?', $params, $op);
    }
1181864
public function whereCmp($field, $operator, $value)
    {
        $bind_key = strpos($field, '.') ? strtr($field, '.', '_') : $field;
        $normalizedField = preg_replace('#\w+#', '[\\0]', $field);

        if ($operator === '=') {
            if ($value === null) {
                $this->_conditions[] = $normalizedField . ' IS NULL';
            } else {
                $this->_conditions[] = $normalizedField . '=:' . $bind_key;
                $this->_bind[$bind_key] = $value;
            }
        } elseif ($operator === '~=') {
            if ($value === 0 || $value === 0.0) {
                $this->_conditions[] = "$normalizedField IS NULL OR $normalizedField=0";
            } elseif ($value === '') {
                $this->_conditions[] = "$normalizedField IS NULL OR $normalizedField=''";
            } else {
                $this->_conditions[] = $normalizedField . '=' . $bind_key;
                $this->_bind[$bind_key] = $value;
            }
        } elseif ($operator === '!=' || $operator === '<>') {
            if ($value === null) {
                $this->_conditions[] = $normalizedField . ' IS NOT NULL';
            } else {
                $this->_conditions[] = $normalizedField . $operator . ':' . $bind_key;
                $this->_bind[$bind_key] = $value;
            }
        } elseif (in_array($operator, ['>', '>=', '<', '<='], true)) {
            $this->_conditions[] = $normalizedField . $operator . ':' . $bind_key;
            $this->_bind[$bind_key] = $value;
        } else {
            throw new MisuseException(['unknown `:operator` operator', 'operator' => $operator]);
        }

        return $this;
    }
786082
public function orWhereInfix($field, $operator = '=', $condition = false)
    {
        $numArgs = func_num_args();
        if ($numArgs > 2) {
            $this->where->addOrCondition($field, $condition, $operator);
        } elseif ($numArgs == 2) {
            $this->where->addOrCondition($field, $operator, '=');
        } else {
            $this->where->addOrCondition($field);
        }

        return $this;
    }
465092
private function addOperator($operator, $field, $value) {
		$this->is($field, array('$' . $operator => $value));
		
		return $this;
	}
725962
public function order($field, $order = null)
    {
        if (!empty($field)) {
            if (is_string($field)) {
                if (!empty($this->options['via'])) {
                    $field = $this->options['via'] . '.' . $field;
                }
                $field = empty($order) ? $field : [$field => $order];
            } elseif (!empty($this->options['via'])) {
                foreach ($field as $key => $val) {
                    if (is_numeric($key)) {
                        $field[$key] = $this->options['via'] . '.' . $val;
                    } else {
                        $field[$this->options['via'] . '.' . $key] = $val;
                        unset($field[$key]);
                    }
                }
            }
            if (!isset($this->options['order'])) {
                $this->options['order'] = [];
            }
            if (is_array($field)) {
                $this->options['order'] = array_merge($this->options['order'], $field);
            } else {
                $this->options['order'][] = $field;
            }
        }
        return $this;
    }
658991
public function OrLike($Field, $Match = '', $Side = 'both', $Op = 'like') {
      if (!is_array($Field))
         $Field = array($Field => $Match);
      
      foreach ($Field as $f => $v) {
         $this->OrOp()->Like($f, $v, $Side, $Op);
      }
      return $this;

//       return $this->OrOp()->Like($Field, $Match, $Side, $Op);
   }
1237472
public function where($field, $op = null, $condition = null) {
        $this->addWhere("AND", $field, $op, $condition);
        return $this;
    }
273556
public function whereEqual($field, $param, string $op = ''): self
    {
        return $this->where($this->prepareField($field) .' = ?', $param, $op);
    }
969729
public function where($field, $value)
    {
        if (!isset($this->_expression[$field]) || !is_array($value) || !is_array($this->_expression[$field])) {
            $this->_expression[$field] = $value;
        } else {
            $this->_expression[$field] = array_merge_recursive($this->_expression[$field], $value);
        }

        return $this;
    }
902478
public function or_where($column, $op = null, $value = null)
	{
		if($column instanceof \Closure)
		{
			$this->or_where_open();
			$column($this);
			$this->or_where_close();
			return $this;
		}

		if (is_array($column))
		{
			foreach ($column as $key => $val)
			{
				if (is_array($val))
				{
					$this->or_where($val[0], $val[1], $val[2]);
				}
				else
				{
					$this->or_where($key, '=', $val);
				}
			}
		}
		else
		{
			if(func_num_args() === 2)
			{
				$value = $op;
				$op = '=';
			}
			$this->_where[] = array('OR' => array($column, $op, $value));
		}
		return $this;
	}