where 语法见 @see WhereRule
@param array|string|callable|null $conditions
@param string $_
@return \PhpBoot\DB\rules\select\WhereRule
574
public function findWhere($conditions=null, $_=null)
    {
        $query =  $this->db->select($this->getColumns())
            ->from($this->entity->getTable());
        $query->context->resultHandler = function ($result){
            foreach ($result as &$i){
                $i = $this->entity->make($i, false);
            }
            return $result;
        };
        return call_user_func_array([$query, 'where'], func_get_args());
    }
1083725
public function conditionsFilter(Model $model, $record, $conditions, $or = false) {
		foreach ($conditions as $field => $value) {
			$return = null;
			if ($value === '') {
				continue;
			}
			if (is_array($value) && in_array(strtoupper($field), array('AND', 'NOT', 'OR'))) {
				switch (strtoupper($field)) {
					case 'AND':
						$return = $this->conditionsFilter($model, $record, $value);
						break;
					case 'NOT':
						$return = !$this->conditionsFilter($model, $record, $value);
						break;
					case 'OR':
						$return = $this->conditionsFilter($model, $record, $value, true);
						break;
				}
			} else {
				if (is_array($value)) {
					$type = 'IN';
				} elseif (preg_match('/^(\w+\.?\w+)\s+(=|!=|LIKE|IN|<|<=|>|>=)$/i', $field, $matches)) {
					$field = $matches[1];
					$type = strtoupper($matches[2]);
				} elseif (preg_match('/^(\w+\.?\w+)\s+(=|!=|LIKE|IN|<|<=|>|>=)\s+(.*)$/i', $value, $matches)) {
					$field = $matches[1];
					$type = strtoupper($matches[2]);
					$value = $matches[3];
				} else {
					$type = '=';
				}
				if (strpos($field, '.') !== false) {
					list($alias, $field) = explode('.', $field, 2);
					if ($alias != $model->alias) {
						continue;
					}
				}
				switch ($type) {
					case '<':
						$return = (isset($record[$field]) && $record[$field] < $value);
						break;
					case '<=':
						$return = (isset($record[$field]) && $record[$field] <= $value);
						break;
					case '=':
						$return = (isset($record[$field]) && $record[$field] == $value);
						break;
					case '>':
						$return = (isset($record[$field]) && $record[$field] > $value);
						break;
					case '>=':
						$return = (isset($record[$field]) && $record[$field] >= $value);
						break;
					case '!=':
						$return = (!isset($record[$field]) || $record[$field] != $value);
						break;
					case 'LIKE':
						$value = preg_replace(array('#(^|[^\\\\])_#', '#(^|[^\\\\])%#'), array('$1.', '$1.*'), $value);
						$return = (isset($record[$field]) && preg_match('#^' . $value . '$#i', $record[$field]));
						break;
					case 'IN':
						$items = array();
						if (is_array($value)) {
							$items = $value;
						} elseif (preg_match('/^\(\w+(,\s*\w+)*\)$/', $value)) {
							$items = explode(',', trim($value, '()'));
							$items = array_map('trim', $items);
						}
						$return = (isset($record[$field]) && in_array($record[$field], (array)$items));
						break;
				}
			}
			if ($return === $or) {
				return $or;
			}
		}
		return !$or;
	}
1006783
public function count($conditions = '', $params = array()){
        return $this->db->builder()->select('COUNT(*)')->from($this->table)->where($conditions, $params)->queryValue();
    }
878214
public static function conditionTextByRow( $conditions, $row )
    {
        $db = eZDB::instance();

        $where_text = "";
        if ( is_array( $conditions ) and
             count( $conditions ) > 0 )
        {
            $where_text = " WHERE  ";
            $i = 0;
            foreach ( $conditions as $id => $cond )
            {
                if ( $i > 0 )
                    $where_text .= " AND ";
                if ( is_array( $row ) )
                {
                    $where_text .= $cond . "='" . $db->escapeString( $row[$cond] ) . "'";
                }
                else
                {
                    if ( is_array( $cond ) )
                    {
                        if ( is_array( $cond[0] ) )
                        {
                            $where_text .= $id . ' IN ( ';
                            $j = 0;
                            foreach ( $cond[0] as $value )
                            {
                                if ( $j > 0 )
                                    $where_text .= ", ";
                                $where_text .= "'" . $db->escapeString( $value ) . "'";
                                ++$j;
                            }
                            $where_text .= ' ) ';
                        }
                        else if ( is_array( $cond[1] ) )
                        {
                            $range = $cond[1];
                            $where_text .= "$id BETWEEN '" . $db->escapeString( $range[0] ) . "' AND '" . $db->escapeString( $range[1] ) . "'";
                        }
                        else
                        {
                          switch ( $cond[0] )
                          {
                              case '>=':
                              case '<=':
                              case '<':
                              case '>':
                              case '=':
                              case '<>':
                              case '!=':
                              case 'like':
                                  {
                                      $where_text .= $db->escapeString( $id ) . " " . $cond[0] . " '" . $db->escapeString( $cond[1] ) . "'";
                                  } break;
                              default:
                                  {
                                      eZDebug::writeError( "Conditional operator '$cond[0]' is not supported.", __METHOD__ );
                                  } break;
                          }

                        }
                    }
                    else
                        $where_text .= $db->escapeString( $id ) . "='" . $db->escapeString( $cond ) . "'";
                }
                ++$i;
            }
        }
        return $where_text;
    }
154108
protected function addConditions($query, $conditions)
    {
        foreach ($conditions as $key => $value) {
            $this->addWhere($query, $key, $value);
        }

        return $query;
    }
675001
public function andWhere($conditions, array $bindParams = null, array $bindTypes = null) {
        if(!is_null($bindParams)) {
            $tmpBindParams = array();
            foreach($bindParams as $key => $value) {
                if(is_int($key)) {
                    $param = 'criteriaHelper' . $this->incrementLocalParamCount();
                    $tmpBindParams[$param] = $value;
                    $conditions = str_replace('?' . $key, ':' . $param . ':', $conditions);
                } else {
                    $tmpBindParams[$key] = $value;
                }
            }
            $bindParams = $tmpBindParams;
        }
        $this->getCriteria()->andWhere($conditions, $bindParams, $bindTypes);
        return $this;
    }
1022544
public function findWhere(array $conditions, $limit = null)
    {
        $result = new ArrayIterator();

        $counter = 0;
        foreach ($this->storage as $row) {
            foreach ($conditions as $field => $criteria) {
                if ($row->offsetGet($field) === $criteria) {
                    $result[] = $row;
                    $counter++;
                }
            }

            if (isset($limit)) {
                if ($counter == $limit) {
                    break;
                }
            }
        }

        if ($result->count() > 0) {
            $this->result = $result;

            if ($result->count() == 1) {
                return $result->first();
            } else {
                return $this->result;
            }
        }

        return false;
    }
1356051
public function where($conditions, array $values){
        if($this->where != ''){$this->where.='AND ';}
        $this->where.= $conditions . ' ';
        $this->where_values = array_merge($this->where_values, $values);
    }
1346529
public function where($key, $condition)
    {
        $this->conditions[$key] = self::$conditionRegex[$condition];
        return $this;
    }
370884
public function generateWhere($conditions, &$where, &$values, &$types)
    {
        $where = "";

        // When empty where, no conditions, return and set where empty.
        if (count($conditions) == 0) {
            return;
        }

        $idx = 0;
        $max = count($conditions);

        foreach ($conditions as $criteria) {
            $column = $criteria['column'];
            $operator = $criteria['operator'];
            $value = $criteria['value'];

            // Prepare where clause
            $where .= "$column ";

            // Check our operator
            if ($operator === "IN") {
                // Prepare and loop
                $where .= "IN (";

                $subIdx = 0;
                $subMax = count($value);
                foreach ($value as $subValue) {

                    $where .= "?";
                    $values[] = $this->prepareData($subValue);
                    $types[] = $this->determinateType($subValue);

                    if (($subIdx+1) < $subMax) {
                        $where .= ",";
                    }
                    $subIdx++;
                }
                $where .= ")";
            } else {
                // Will add a normal operator
                $where .= "$operator ";

                $where .= "?";
                $values[] = $this->prepareData($value);
                $types[] = $this->determinateType($value);
            }

            // Adding AND if not last
            if (($idx + 1) < $max) {
                $where .= " AND ";
            }
            $idx++;
        }
    }
629547
public function where($conditions): self
    {
        if ($conditions[0] instanceof Closure) {
            $this->addClauseCondClosure('where', 'AND', $conditions[0]);

            return $this;
        }
        $this->where[] = ['and', $conditions];

        return $this;
    }
1191460
public function andWhere(...$conditions) : self
    {
        $this->conditionalQueryBuilder->andWhere(
            ...$this->createConditionExpressions($conditions)
        );

        return $this;
    }
958982
function where( $condition, $params = array() ) {

        $clone = clone $this;

        // conditions in key-value array
        if ( is_array( $condition ) ) {

            foreach ( $condition as $c => $params ) {

                $clone = $clone->where( $c, $params );

            }

            return $clone;

        }

        // shortcut for basic "column is (in) value"
        if ( preg_match( '/^[a-z0-9_.`"]+$/i', $condition ) ) {

            $clone->where[] = $clone->db->is( $condition, $params );

            return $clone;

        }

        if ( !is_array( $params ) ) {

            $params = func_get_args();
            array_shift( $params );

        }

        $clone->where[] = $condition;
        $clone->whereParams = array_merge( $clone->whereParams, $params );

        return $clone;

    }
1202319
public function findAllBy(array $conditions = array())
    {
        $sql = sprintf('SELECT * FROM %s', $this->getTableName());
        $whereConditions = $this->assembleEquality($conditions);
        $where = sprintf('WHERE %s', implode(' AND ', $whereConditions));
        $sql .= " $where";

        return $this->selectQuery($sql, $conditions);
    }
167645
private static function fetchByConditions( $conditions, $limit, $offset )
    {
        $db = eZDB::instance();

        $defaultConditions = array(
            'ezcobj_state.group_id=ezcobj_state_group.id',
            'ezcobj_state_language.contentobject_state_id=ezcobj_state.id',
            eZContentLanguage::languagesSQLFilter( 'ezcobj_state' ),
            eZContentLanguage::sqlFilter( 'ezcobj_state_language', 'ezcobj_state' )
        );

        $conditions = array_merge( $conditions, $defaultConditions );

        $conditionsSQL = implode( ' AND ', $conditions );

        $sql = "SELECT ezcobj_state.*, ezcobj_state_language.* " .
               "FROM ezcobj_state, ezcobj_state_group, ezcobj_state_language " .
               "WHERE $conditionsSQL " .
               "ORDER BY ezcobj_state.priority";

        $rows = $db->arrayQuery( $sql, array( 'limit' => $limit, 'offset' => $offset ) );

        $states = array();
        foreach ( $rows as $row )
        {
            $state = new eZContentObjectState( $row );
            $stateLanguage = new eZContentObjectStateLanguage( $row );
            $state->setLanguageObject( $stateLanguage );
            $states[] = $state;
        }

        return $states;
    }
783966
public function get($conditions)
    {
        $query = $this->db->getQuery(true);

        $query->select('*')
            ->from($query->quoteName($this->table))
            ->where('id = :id')
            ->bind('id', $conditions);

        return $this->db->setQuery($query)->loadOne('assoc');
    }
274005
public function orWhere(...$conditions) : self
    {
        $this->conditionalQueryBuilder->orWhere(
            ...$this->createConditionExpressions($conditions)
        );

        return $this;
    }