resolve model instance
@param array $where
@return Eloquent
346112
protected function resolveModel(array $where)
    {
        $model = $this->fieldData->query()->where($where)->first();
        return (is_null($model)) ? $this->fieldData->newInstance($where) : $model;
    }
635440
public function findWhere(array $where, $columns = ['*'])
    {
        $this->newQuery();

        foreach ($where as $field => $value) {
            if (is_array($value)) {
                list($field, $condition, $val) = $value;
                $this->query->where($field, $condition, $val);
            }
            else {
                $this->query->where($field, '=', $value);
            }
        }

        return $this->query->get($columns);
    }
1117787
public final function inflateFromDB($where) {
        $data = $this->loadFromDb($where);
        if (!$data) {//加载失败时将条件做为数据填充
            $data = $where;
        }

        return $this->inflateByData($data);
    }
1273273
public function fresh($with = [])
    {
        if (! $this->exists) {
            return;
        }

        return static::newQueryWithoutScopes()
                        ->with(is_string($with) ? func_get_args() : $with)
                        ->where($this->getKeyName(), $this->getKey())
                        ->first();
    }
1106550
public function findAll(array $where = [], array $field = [])
    {
        return $this
            ->createQuery(
                $this->getQueryBuilder()
                    ->select(array() === $field ? $this->getAlias() : $field)
                    ->from($this->getTable())
                    ->where($where)
            )
            ->execute()
            ->getAll()
            ;
    }
232049
public function recordWhereCache($model, $where) {
        /* @var $t Record */
        $t = new $model;
        $cacheKeys = $t->cacheKeys();
        if (!$cacheKeys) {
            return null;
        }
        ksort($where);
        $key = implode(",", array_keys($where));
        foreach ($cacheKeys as $cacheKey) {
            $m = explode(',', $cacheKey);
            sort($m);
            $cacheKey = implode(",", $m);
            if ($key == $cacheKey) {
                $cache_key = "record_" . $model . "_" . $key . "_" . implode(",", array_values($where));
                $data = Cache::get($cache_key);
                if ($data) {
                    Log::debug("命中缓存 " . $model . " 条件:" . json_encode($where), 'cache');
                    $t->fromDbData($data);
                    return $t;
                }
                break;
            }
        }
        return null;
    }
1207646
protected function where($where)
    {
        foreach($where as $field => $value) {
            $this->queryBuilder->where($field, $value);
        }
    }
585993
public function exist($where = null): Statement
    {
        $this->operation = 'exist';
        $this->fields = '*';
        if ($where) {
            $this->where = $where;
        }
        return $this;
    }
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);
            }
        }
    }
568102
public function firstOrCreate(array $where)
    {
        $this->applyCriteria();
        $this->applyScope();
        $model = $this->model->firstOrCreate($where);
        $this->resetModel();

        event(new RepositoryEntityCreated($this, $model));

        return $this->parserResult($model);
    }
1345292
protected function in(array $where): string
	{
		$values = $this->params($where['values'], false);

		return $this->column($where['column']) . ($where['not'] ? ' NOT IN ' : ' IN ') . '(' . $values . ')';
	}
29326
public function fetchPaginator($where = null)
    {
        if ($where instanceof DbSelect) {
            $adapter = $where;
        } else {
            $select = $this->sql->select();

            if ($where instanceof \Closure) {
                $where($select);
            } elseif ($where !== null) {
                $select->where($where);
            }

            if (count($select->getRawState(Select::GROUP))) {
                $adapter = new DbSelect($select, $this->getAdapter(), $this->getResultSetPrototype());
            } else {
                $count   = null;
                $adapter = new Callback(
                    function ($offset, $itemCountPerPage) use ($select) {
                        $select->offset($offset);
                        $select->limit($itemCountPerPage);

                        $statement = $this->sql->prepareStatementForSqlObject($select);
                        $result    = $statement->execute();

                        $resultSet = $this->getResultSetPrototype() ? clone $this->getResultSetPrototype() : new ResultSet();
                        $resultSet->initialize($result);
                        return $resultSet;
                    }, function () use ($select, &$count) {
                        if ($count === null) {
                            $select = clone $select;
                            $select->columns(array('Gzfextra_Db_Count' => new Expression('count(1)')));
                            $result = $this->sql->prepareStatementForSqlObject($select)->execute()->current();
                            $count  = $result['Gzfextra_Db_Count'];
                        }
                        return $count;
                    }
                );
            }
        }

        return new Paginator($adapter);
    }
761952
public function count(array $where = [])
    {
        $sql = $this->createQueryBuilder('data');
        $sql->select('COUNT(data)');
        if (\count($where)) {
            foreach ($where as $key => $value) {
                $sql->andWhere('data.' . $key . ' = :' . $key);
                $sql->setParameter($key, $value);
            }
        }

        return $sql->getQuery()->getSingleScalarResult();
    }
1374296
public function delete($table, array $where)
    {
        $keys = array_keys($where);
        $values = array_values($where);

        $replace = function ($key) { return $key . "=?"; };

        $where = implode(' AND ', array_map($replace, $keys));

        $sql = "DELETE FROM {$table} WHERE {$where}";

        return $this->query($sql, $values);
    }
565918
public function delete($table, array $where)
    {
        $query = "DELETE FROM `$table` WHERE ";

        $bind = array();
        foreach ($where as $column => $value) {
            $query .= "`$column` = ? AND ";
            $bind[] = $value;
        }

        $query = substr($query, 0, -5);

        // Prepare, bind and execute
        $statement = $this->prepare($query);
        foreach ($bind as $idx => $value) {
            $statement->bindValue(($idx + 1), $value, Database::typeOfValue($value));
        }

        return $statement->execute();
    }
241384
protected function _whereExpr($where)
    {
        if (empty($where)) {
            return $where;
        }
        if (!is_array($where)) {
            $where = array($where);
        }
        foreach ($where as $cond => &$term) {
            // is $cond an int? (i.e. Not a condition)
            if (is_int($cond)) {
                // $term is the full condition
                if ($term instanceof Zend_Db_Expr) {
                    $term = $term->__toString();
                }
            } else {
                // $cond is the condition with placeholder,
                // and $term is quoted into the condition
                $term = $this->quoteInto($cond, $term);
            }
            $term = '(' . $term . ')';
        }

        $where = implode(' AND ', $where);
        return $where;
    }
301237
public function delete($where)
    {
        $tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
        return $this->_db->delete($tableSpec, $where);
    }