whereArr

Upgrade the WHERE method

@param  Array  $conditions Array of arrays
@return Model
979522
public static function arrWhere(Array $conditions)
    {

        $model = static::class;
        $obj = new $model();

        foreach ($conditions as $condition) {
            if (count($condition) == 2) {
                $obj = $obj->where($condition[0], $condition[1]);
            } elseif (count($condition) == 3) {
                if (strtolower(trim($condition[1])) === 'between') {
                    $obj = $obj->whereBetween($condition[0], $condition[2]);
                } else {
                    $obj = $obj->where($condition[0], $condition[1], $condition[2]);
                }
            } elseif (count($condition) == 4) {
                if (strtolower(trim($condition[1])) === 'between') {
                    $obj = $obj->whereBetween($condition[0], $condition[2], $condition[3]);
                } else {
                    $obj = $obj->where($condition[0], $condition[1], $condition[2], $condition[3]);
                }
            } else {
                throw new \Exception("Invalid " . strtoupper($key) . " condition", 1);
            }
        }

        return $obj;
    }
1222260
public static function select(...$conditions)
    {
        $keys = [];
        foreach($conditions as $condition)
        {
            $keys[] = static::generateKey($condition);
        }
        $datas = static::__getRedis()->mGet($keys);
        $list = [];
        foreach($datas as $data)
        {
            if(null !== $data)
            {
                $list[] = static::newInstance($data);
            }
        }
        return $list;
    }
372021
public static function filter(array $conditions)
    {

        $model = static::class;
        $obj = new $model();

        foreach ($conditions as $key => $condition) {

            if (is_array($condition)) {
                if (count($condition) == 1) {
                    $obj = $obj->where($key, $condition[0]);
                } elseif (count($condition) == 2) {
                    if (strtolower(trim($condition[0])) === 'between') {
                        $obj = $obj->whereBetween($key, $condition[1]);
                    } else {
                        $obj = $obj->where($key, $condition[0], $condition[1]);
                    }
                } elseif (count($condition) == 3) {
                    if (strtolower(trim($condition[0])) === 'between') {
                        $obj = $obj->whereBetween($key, $condition[1], $condition[2]);
                    } else {
                        $obj = $obj->where($key, $condition[0], $condition[1], $condition[2]);
                    }
                } else {
                    throw new \Exception("Invalid " . strtoupper($key) . " condition", 1);
                }
            } else {
                if (is_numeric($condition) || is_bool($condition)) {
                    $obj = $obj->where($key, $condition);
                } elseif (is_string($condition)) {
                    $obj = $obj->where($key, 'LIKE', $condition);
                } elseif (is_null($condition)) {
                    $obj = $obj->whereNull($key);
                } else {
                    throw new \Exception("Invalid " . strtoupper($key) . " condition", 2);
                }
            }
        }

        return $obj;
    }
1180641
public function where(\Parable\ORM\Query\ConditionSet $set)
    {
        $this->where[] = $set;
        return $this;
    }
695671
public function update($values, $conditions, $params = array()){
        return $this->db->builder()->update($this->table, $values, $conditions, $params);
    }
431286
public function orWhere($wheres = array())
		{
			if (count($wheres) > 0) {
				if ( ! isset($this->wheres['$or']) or ! Arrays::is($this->wheres['$or'])) {
					$this->wheres['$or'] = array();
				}

				foreach ($wheres as $wh => $val) {
					$this->wheres['$or'][] = array($wh => $val);
				}
			}

			return $this;
		}
1260107
public function findBy(array $conditions)
    {
        $s = $this->selector();
        foreach ($conditions as $column => $value) {
            $s->where($column, '=', $value);
        }

        return $s->execute();
    }
855845
protected function findByParams($where)
    {
        $model = $this->makeModel()->getModel()->widgetParams()->getModel()->newQuery();
        return $model->where($where)->get()->toArray();
    }
146078
public static function find(array $where) {
        $model = get_called_class();
        /* @var $t Record */
        $t = new $model;
        /* @var $db_cache DBCache */
        $db_cache = Ioc::get(DBCache::class);
        $data = $db_cache->recordWhereCache($model, $where);
        if ($data) {
            return $data;
        }
        /* @var $data Record */
        $select = DB::select($t->getTable())->where($where)->setRecord($model);
        Event::trigger('record_before_select', [$t, $select]);
        $data = $select->find();
        $db_cache->recordWhereCacheSave($model, $where, $data->_db_data);
        return $data;
    }
533657
protected function _setWhere($condition, $operation = 'AND')
    {

        if (is_string($condition)) {
            $this->where[] = [
                'condition' => $condition,
                'operation' => $operation
            ];
            return $this;
        }

        if (is_array($condition) || ($condition instanceof \Traversable)) {
            $conditions = [];
            foreach ($condition as $predicate => $param) {
                if (is_array($param) || ($param instanceof \Traversable)) {
                    //param has multiple entries
                    foreach ($param as $key => $value) {
                        if (preg_match('/:[a-z_]*/i', $key)) {
                            $this->parameters[$key] = $value;
                        } else {
                            $this->parameters[] = $value;
                        }
                    }
                } elseif (!is_numeric($predicate)) {
                    $this->parameters[] = $param;
                } else {
                    $predicate = $param;
                }
                $conditions[] = $predicate;
            }
            $this->where[] = [
                'condition' => count($conditions) > 1 ?
                        '('. implode(' AND ', $conditions) .')' :
                        $conditions[0],
                'operation' => $operation
            ];
        }
        return $this;
    }
1140484
protected function makeConditions(array $conditions): ?\SplObjectStorage
    {
        if (empty($conditions)) {
            return null;
        }

        $storage = new \SplObjectStorage();
        foreach ($conditions as $condition => $options) {
            $condition = $this->config->resolveAlias($condition);

            if ($this->config->hasCondition($condition)) {
                $autowire = $this->config->getCondition($condition);
            } else {
                $autowire = new Autowire($condition);
            }

            $storage->attach($autowire->resolve($this->factory), $options);
        }

        return $storage;
    }
301508
public function where($condition, $value = null): object
    {
        if (!is_array($condition)) {
            $condition = [$condition => $value];
        }
        $this->container[$this->id]['s']['where'] = array_merge($this->container[$this->id]['s']['where'], $condition);
        return $this;
    }
591650
public function sequence(array $conditions) {
      $range = new Collection();
      foreach ($conditions as $value) {
        $range[] = $this->checkFromSequence($value);
      }

      return $range;
    }
276445
protected function applyConditions(array $where)
    {
        foreach ($where as $field => $value) {
            if (is_array($value)) {
                list($field, $condition, $val) = $value;
                $this->model = $this->model->where($field, $condition, $val);
            } else {
                $this->model = $this->model->where($field, '=', $value);
            }
        }
    }
317210
public function matchItem(array $conditions)
    {
        $this->validateConditions($conditions);

        foreach ($conditions as $key => $values) {

            $query = new Query();
            $query->limit = self::INT_MAX_16BIT;
            if (isset($query->performCount)) $query->performCount = false;
            $query->filter = $this->getQueryCriterion($key, $values);
            $results = $this->repository->getTrashService()->findTrashItems($query);

            $items = [];
            foreach ($results->items as $result) {
                $items[$result->id] = $result;
            }

            return new TrashedItemCollection($items);
        }
    }
1250094
public function orHaving(...$conditions) : self
    {
        $this->havingConditions = $this->conditionalQueryBuilder->addConditionToClause(
            $this->havingConditions, 'OR', ...$this->createConditionExpressions($conditions)
        );

        return $this;
    }
52585
protected function whereArray(array $wheres)
    {
        foreach ($wheres as $name => $expression) {
            $this->where($name, $expression);
        }

        return $this;
    }