Filter data - get one row
@param array $condition
@return ArrayDataSource
979377
public function filterOne(array $condition)
	{
		foreach ($this->data as $item) {
			foreach ($condition as $key => $value) {
				if ($item[$key] == $value) {
					$this->setData([$item]);

					return $this;
				}
			}
		}

		$this->setData([]);

		return $this;
	}
1061567
public function findWhere(array $conditions, $limit = null)
    {
        $result = $this->db
            ->from($this->collection)
            ->getWhere($conditions, $limit);

        if ($result->count() > 0) {
            $this->result = new DataObjects\Result($result, $this);

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

            return $this->result;
        }

        return false;
    }
329693
public function where(array $condition = null): Select
    {
        if (!\is_array($condition)) {
            throw new InvalidArgumentException('$condition has to be an array');
        }
        $this->where = (new Condition($this->namesClass->getAliases()))->parse($condition);

        return $this;
    }
1263005
public function parseCondition($condition)
    {
        if (strpos($condition, ':')) {
            $condition = ' ' . substr(strstr($condition, ':'), 1);
        }

        $condition = str_ireplace(array_keys($this->comparison), array_values($this->comparison), $condition);
        $this->tpl->parseVar($condition);

        // $this->tpl->parseVarFunction($condition); // XXX: 此句能解析表达式中用|分隔的函数，但表达式中如果有|、||这样的逻辑运算就产生了歧异
        return $condition;
    }
164853
public function current(array $condition)
    {
        $value = strtotime(reset($condition['value']));
        return empty($value) ? false : $this->compare(GC_TIME, $value, $condition['operator']);
    }
990781
public function fetchAll($conditions = false)
    {
        $this->andWhere($conditions);
        $data = $this->execute();
        if ($this->indexBy) {
            $data = $this->executeIndexBy($data, $this->indexBy);
        }
        return $data;
    }
53756
public static function random(array $conditions = [])
    {
        $count = static::entity()->getDatabase()->count(static::$collection, $conditions);
        if ($count === 0) {
            return null;
        }

        $data = static::find($conditions, [], 1, rand(0, $count));

        return $data[0];
    }
1077488
public function findAll(Condition $condition = null): array
    {
        $result = [];
        $rows = $this->microDb->getCollection($this->collectionName)->fetchAll(
            $this->conditionParser->filter($condition, $limit, $offset),
            $this->conditionParser->sort($condition),
            $limit,
            $offset
        );
        foreach ($rows as $row) {
            /** @var AbstractEntity $entity */
            $entity = $this->factory->create();
            $entity->mapFromArray($row);
            $result[$entity->getId()] = $entity;
        }

        return $result;
    }
595859
public function finds($condition = NULL, $rows = 0, $start = 0, $order='', $fields = '*', $fetchMode=PDO::FETCH_ASSOC) {
		if (is_array($condition)) {
			$where = $condition[0];
			$params = $condition[1];
		} 
		else {
			$where = $condition;
			$params = null;
		}
		return $this->driver
            ->field($fields)
            ->where($where, $params)
            ->orderby($order)
            ->limit($rows, $start)
            ->fetchAll($fetchMode);
	}
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;
    }
615078
public function where($condition) {
        if (is_array($condition)) {
            $this->condition = new ArrayCondition($condition);
        } elseif ($condition instanceof ConditionInterface) {
            $this->condition = $condition;
        } else {
            throw new InvalidSQLConditionException('无效的SQL条件');
        }

        $this->condition->setStatementContext($this->statementContext);

        return $this;
    }
44494
protected function parseCondition($condition)
    {
        $tableAlias = $this->getAlias();
        $parts = [];

        if ($condition instanceof QueryBuilderAwareInterface) {
            $condition->setQueryBuilder($this);
        }

        if ($condition instanceof Expression) {
            $parts[] = $this->getAdapter()->quoteSql($condition->toSQL());
        } elseif ($condition instanceof Q) {
            $condition->setLookupBuilder($this->getLookupBuilder());
            $condition->setAdapter($this->getAdapter());
            $condition->setTableAlias($tableAlias);
            $parts[] = $condition->toSQL();
        } elseif ($condition instanceof ToSqlInterface) {
            $parts[] = $condition->toSQL();
        } elseif (is_array($condition)) {
            foreach ($condition as $key => $value) {
                if ($value instanceof Q) {
                    $parts[] = $this->parseCondition($value);
                } else {
                    list($lookup, $column, $lookupValue) = $this->lookupBuilder->parseLookup($this, $key, $value);
                    $column = $this->getLookupBuilder()->fetchColumnName($column);
                    if (false === empty($tableAlias) && false === strpos($column, '.')) {
                        $column = $tableAlias.'.'.$column;
                    }
                    $parts[] = $this->lookupBuilder->runLookup($this->getAdapter(), $lookup, $column, $lookupValue);
                }
            }
        } elseif (is_string($condition)) {
            $parts[] = $condition;
        } elseif ($condition instanceof Expression) {
            $parts[] = $condition->toSQL();
        }

        if (1 === count($parts)) {
            return $parts[0];
        }

        return '('.implode(') AND (', $parts).')';
    }
144986
public function id(array $condition, array $data)
    {
        if (empty($data['product_id'])) {
            return false;
        }

        return $this->compare($data['product_id'], $condition['value'], $condition['operator']);
    }
1141162
public function roleId(array $condition)
    {
        $role_id = $this->user->getRoleId();
        return $this->compare($role_id, $condition['value'], $condition['operator']);
    }
483600
public function reject( $condition ) {
		return $this->filter( function ( $v, $k ) use ( $condition ) {
			return ! call_user_func( $condition, $v, $k );
		} );
	}
1051488
public static function findAll($condition = '1=1', $params = array())
    {
        /* @var $condition \mpf\datasources\sql\ModelCondition */
        if (!is_a($condition, '\\mpf\\datasources\\sql\\ModelCondition')) {
            $condition = ModelCondition::getFrom($condition, get_called_class());
        } else {
            $condition->model = $condition->model ? $condition->model : get_called_class();
        }
        $condition->setParams($params);
        $searchedRelations = [];
        if (is_array($condition->with)) {
            foreach ($condition->with as $k) {
                $searchedRelations[$k] = $k;
            }
        }
        $models = static::getDb()->queryClass($condition, get_called_class(), $condition->getParams(), [
            [
                '_columns' => static::getDb()->getTableColumns(static::getTableName()),
                '_pk' => static::getDb()->getTablePk(static::getTableName()),
                '_isNewRecord' => false,
                '_action' => 'update',
                '_tableName' => static::getTableName(),
                '_db' => static::getDb(),
                '_searchedRelations' => $searchedRelations
            ]
        ]);
        if (!$models) {
            return [];
        }
        $condition->getExtraRelations($models);
        return $models;
    }
1178817
public static function getListQuery( ?array $condition = [], $key = null, $value = null, $indexBy = true, $orderBy = true, $alias = null )
	{
		
		if( !$alias && is_subclass_of( get_called_class(), ActiveRecord::class ) ) {
			$table = Yii::$app->db->schema->getRawTableName( ( get_called_class() )::tableName() );
		}
		else if( $alias ) {
			$table = $alias;
		}
		else {
			$table = '';
		}
		
		!$table ?: $table .= '.';
		
		$key   = $key ?? static::primaryKey()[0];
		$value = $value ?? $key;
		
		$query = static::find()
		               ->select( [
			               $table . $value,
			               $table . $key,
		               ] )
		               ->andFilterWhere( $condition ?? [] )
		;
		
		if( $orderBy === true ) { //
			$query->orderBy( $table . $value );
		}
		else if( $orderBy !== false ) { //
			$query->orderBy( $table . $orderBy );
		}
		
		if( $indexBy === true ) { //
			$query->indexBy( $key );
		}
		else if( $indexBy !== false ) { //
			$query->indexBy( $indexBy );
		}
		
		return $query;
	}