自动获取条件
@return Query|bool
356477
public function getPrimaryKeyQuery() {
        if (!empty($this->primaryKey)
            && $this->hasAttribute($this->primaryKey)) {
            return static::query()->where($this->primaryKey,
                $this->getAttributeSource($this->primaryKey));
        }
        return false;
    }
1345189
public function process()
    {
        $value = $this->value();
        if ($value === null) {
            return false;
        }

        $isMultiValue = is_array($value);
        if ($isMultiValue &&
            empty($value)
        ) {
            return false;
        }

        if (!$this->manager()->getRepository() instanceof Table) {
            foreach ($this->fields() as $field) {
                $this->getQuery()->where([
                    $field => $value,
                ]);
            }

            return true;
        }

        $expressions = [];
        foreach ($this->fields() as $field) {
            $expressions[] = function (QueryExpression $e) use ($field, $value, $isMultiValue) {
                if ($isMultiValue) {
                    return $e->in($field, $value);
                }

                return $e->eq($field, $value);
            };
        }

        $this->getQuery()->andWhere([$this->getConfig('mode') => $expressions]);

        return true;
    }
970161
final public function getQuery()
    {
        if (null === $this->query) {

            $this->query = $this->buildQuery();

            // Apply conditions.
            foreach ($this->conditions as $statement => $value) {
                $this->applyOperator($this->query, $statement, $value);
            }

            $limit = $this->getLimit();

            if (CursorInterface::LIMIT_NONE !== $limit) {
                $this->query->range($this->getOffset(), $limit);
            }
        }

        return $this->query;
    }
691912
public function process()
    {
        $value = $this->value();
        if (!is_scalar($value) || $value === '') {
            return false;
        }

        $bool = (bool)$value;

        $nullValue = $this->getConfig('nullValue');
        $comparison = ' !=';
        if (!$bool) {
            $comparison = '';
        }
        if ($nullValue === null) {
            $comparison = ' IS NOT';
            if (!$bool) {
                $comparison = ' IS';
            }
        }

        if (!$this->manager()->getRepository() instanceof Table) {
            foreach ($this->fields() as $field) {
                $this->getQuery()->where([
                    $field . $comparison => $nullValue,
                ]);
            }

            return true;
        }

        $conditions = [];
        foreach ($this->fields() as $field) {
            $conditions[] = [$field . $comparison => $nullValue];
        }

        $this->getQuery()->andWhere([$this->getConfig('mode') => $conditions]);

        return true;
    }
385635
public function count()
    {
        if ($this->numberOfRows === null) {
            if (is_array($this->rows)) {
                $this->numberOfRows = count($this->rows);
            } else {
                $this->numberOfRows = $this->query->count();
            }
        }
        return $this->numberOfRows;
    }
1259258
public function query()
    {
        // Query every server using it's domain name.
        for ($i = 0; $i < $this->numservers; $i++) {
            $result = $this->querySingleServer($this->server[$i]);
            if ($this->debug) {
                echo "server: {$this->server[$i]}\n";
                echo "result: $result\n";
            }

            if ($result) {
                return $result;
            }
        }
        return false;
    }
1044746
public function count()
    {
        if ($this->_rowCount === null) {
            $rowCount = $this->_query->count();
            $this->setRowCount($rowCount);
        }

        return $this->_rowCount;
    }
1370794
public function httpQuery()
    {

        //echo ini_get('allow_url_fopen');
        //if (ini_get('allow_url_fopen'))
        $lines = @file($this->query['server']);

        if (!$lines) {
            return false;
        }

        $output = '';
        $pre = '';

        while (list($key, $val) = each($lines)) {
            $val = trim($val);

            $pos = strpos(strtoupper($val), '<PRE>');
            if ($pos !== false) {
                $pre = "\n";
                $output .= substr($val, 0, $pos) . "\n";
                $val = substr($val, $pos + 5);
            }
            $pos = strpos(strtoupper($val), '</PRE>');
            if ($pos !== false) {
                $pre = '';
                $output .= substr($val, 0, $pos) . "\n";
                $val = substr($val, $pos + 6);
            }
            $output .= $val . $pre;
        }

        $search = array(
            '<BR>', '<P>', '</TITLE>',
            '</H1>', '</H2>', '</H3>',
            '<br>', '<p>', '</title>',
            '</h1>', '</h2>', '</h3>');

        $output = str_replace($search, "\n", $output);
        $output = str_replace('<TD', ' <td', $output);
        $output = str_replace('<td', ' <td', $output);
        $output = str_replace('<tr', "\n<tr", $output);
        $output = str_replace('<TR', "\n<tr", $output);
        $output = str_replace('&nbsp;', ' ', $output);
        $output = strip_tags($output);
        $output = explode("\n", $output);

        $rawdata = array();
        $null = 0;

        while (list($key, $val) = each($output)) {
            $val = trim($val);
            if ($val == '') {
                if (++$null > 2) {
                    continue;
                }
            } else {
                $null = 0;
            }
            $rawdata[] = $val;
        }
        return $rawdata;
    }
806567
public function delete()
    {
        $query = $this->createQuery();
        $query->setAction('delete');
        $query->where($query->buildAndSet([$this->getTableKey(), '=', $this->id]));
        $result = $this->database->query($query);

        return $result ? true : false;
    }
705294
public function query()
    {
        $this->applyCriteria();

        if ($this->model instanceof Model) {
            return $this->model->query();
        }

        return clone $this->model;
    }
446785
public function getQuery()
    {
        $sql = $this->prepareSelectString();
        $sql .= $this->prepareJoinString();
        $sql .= $this->prepareWhereString();
        $sql .= $this->prepareGroupByString();
        $sql .= $this->prepareHavingString();
        $sql .= $this->prepareOrderByString();
        $sql .= $this->prepareLimitString();

        return $sql;
    }
190679
public function  exist(){
      $sql = $this->StringSql();
      $existsSql = "exists (".$sql.")";
      $select = 'select '.$existsSql;
      $this->initialize();
      return (bool) $this->query($select)->one()[$existsSql];
  }
1293706
public function query()
    {
        $query = app($this->model)->query()->where('resource', $this->resource->getMorphClass());

        return $this->applyScopes($query);
    }
911878
protected function baseQuery()
    {
        if (empty($this->baseQuery)) {
            if (isset($this->parent->{$this->foreignKey})) {
                // 关联查询带入关联条件
                $this->query->where($this->localKey, '=', $this->parent->{$this->foreignKey});
            }

            $this->baseQuery = true;
        }
    }
763828
public function exists() : bool
    {
        $query = static::createQuery();
        $pks = static::getPrimaryKeys();
        $pkValues = $this->getPrimaryKeyValues();

        if (count($pks) != count($pkValues)) {
            return false;
        }

        $filterFunction = function (WhereClause $whereClause) use (&$pkValues, $query) {
            foreach ($pkValues as $field => $value) {
                $whereClause->and($field, '=', '?');
                $query->bind($value);
            }
        };
        $query->where($filterFunction)
            ->count('*');

        $row = $query->execute()->fetch();

        return $row['all_count'] > 0;
    }
589792
public function query()
    {
        $currentUser = $this->request->user($this->request->route('guard'));

        $query = $currentUser->isA('superadmin') ? app($this->model)->query() : app($this->model)->query()->whereIn('id', $currentUser->roles->pluck('id')->toArray());

        return $this->applyScopes($query);
    }
503822
public function fetch()
    {
        if ($this->resourceHandle !== null) {
            if (($row = $this->resourceHandle->fetch(\PDO::FETCH_ASSOC)) === false) {
                $this->freeResult();
            }

            return $row;
        }

        return false;
    }