Executes a SELECT query and returns a generator that lets you iterate over the results.

@param  mixed      ...$fetchMode Fetch mode
@return \Generator
337693
protected function fetchYield(...$fetchMode): Generator
	{
		$query = $this->compiler->select();

		yield from $this->connection->yield($query['sql'], $query['params'], ...$fetchMode);
	}
392464
protected function getLockTablesSql($lockMode)
    {
        $tableName = $this->class->table->getQuotedQualifiedName($this->platform);

        return $this->platform->appendLockHint(
            'FROM ' . $tableName . ' ' . $this->getSQLTableAlias($this->class->getTableName()),
            $lockMode
        );
    }
712674
public function fetch(int $fetch_style = \PDO::FETCH_ASSOC, int $cursor_orientation = null, int $cursor_offset = null)
    {
        $this->execute();
        
        return $this->stmt->fetch($fetch_style, $cursor_orientation, $cursor_offset);
    }
895456
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
    {
        if (! is_resource($this->result)) {
            return false;
        }

        $fetchMode = $fetchMode ?: $this->defaultFetchMode;

        switch ($fetchMode) {
            case FetchMode::COLUMN:
                return $this->fetchColumn();

            case FetchMode::ASSOCIATIVE:
                return sasql_fetch_assoc($this->result);

            case FetchMode::MIXED:
                return sasql_fetch_array($this->result, SASQL_BOTH);

            case FetchMode::CUSTOM_OBJECT:
                $className = $this->defaultFetchClass;
                $ctorArgs  = $this->defaultFetchClassCtorArgs;

                if (func_num_args() >= 2) {
                    $args      = func_get_args();
                    $className = $args[1];
                    $ctorArgs  = $args[2] ?? [];
                }

                $result = sasql_fetch_object($this->result);

                if ($result instanceof stdClass) {
                    $result = $this->castObject($result, $className, $ctorArgs);
                }

                return $result;

            case FetchMode::NUMERIC:
                return sasql_fetch_row($this->result);

            case FetchMode::STANDARD_OBJECT:
                return sasql_fetch_object($this->result);

            default:
                throw new SQLAnywhereException('Fetch mode is not supported: ' . $fetchMode);
        }
    }
384006
public function fetch(int $fetchStyle = \PDO::FETCH_ASSOC, int $cursorOrientation = \PDO::FETCH_ORI_NEXT, int $cursorOffset = 0)
    {
        // 游标
        switch($cursorOrientation)
        {
            case \PDO::FETCH_ORI_NEXT:
                $row = $this->data[$this->cursor++] ?? false;
                break;
            case \PDO::FETCH_ORI_PRIOR:
                $row = $this->data[--$this->cursor] ?? false;
                break;
            case \PDO::FETCH_ORI_FIRST:
                $row = $this->data[$this->cursor = 0] ?? false;
                break;
            case \PDO::FETCH_ORI_LAST:
                $row = $this->data[$this->cursor = count($this->data) - 1] ?? false;
                break;
            case \PDO::FETCH_ORI_ABS:
                $row = $this->data[$this->cursor += $cursorOffset] ?? false;
                break;
            case \PDO::FETCH_ORI_REL:
                $row = $this->data[$this->cursor = $cursorOffset] ?? false;
                break;
            default:
                throw new \InvalidArgumentException('Statement fetch $cursorOrientation can not use ' . $cursorOrientation);
        }
        if(false === $row)
        {
            return false;
        }
        // 结果集
        return $this->fetchAllParser->getFetchParser()->parseRow($row, $fetchStyle, $this->columnBinds);
    }
857214
public function all($callable = null, $fetchStyle = 0)
    {
        if ($callable === null) {
            return $this->statement->fetchAll($fetchStyle);
        }
        return $this->statement->fetchAll($fetchStyle | PDO::FETCH_FUNC, $callable);
    }
732815
private function getFetchConfig($mode, $fetchArgument = null, array $ctorArgs = [])
    {
        if ($this->fetchConfig) {
            return $this->fetchConfig;
        }

        return $this->createFetchConfig($mode, $fetchArgument, $ctorArgs);
    }
726869
public function setFetchConfig($mode, $fetchArgument = null, array $ctorArgs = [])
    {
        $this->fetchConfig = $this->createFetchConfig($mode, $fetchArgument, $ctorArgs);

        return true;
    }
45935
protected function statement($query, $fetchMode=null)
    {

        return $this->attempt(function () use ($query, $fetchMode) {

            $statement = $this->pdo()->prepare("$query");

            if ($fetchMode !== null) {
                $statement->setFetchMode($fetchMode);
            }
            return $statement;
        }, $query);

    }
408269
protected function runPrepared($query, array $bindings, $fetchMode=null)
    {
        return $this->attempt(function () use ($query, $bindings) {

            $statement = $this->prepared($query, $bindings);
            $statement->execute();

            return $statement;
        }, $query);

    }
1111232
private function fetch($getData=true) {
      try{
         $this->connection();
         $this->resultset = $this->id_conn->prepare($this->sql);
         $this->resultset->execute($this->placeholder_data);
         $this->resultset->setFetchMode( $this->{'FETCH_' . strtoupper( $this->type_fetch )} );
         if ( $getData ) {
            $this->rows     = $this->resultset->fetchAll();
            $this->rowCount = $this->resultset->rowCount();
            // while ( $row = $this->resultset->fetch() ) {
            //    $this->rows[] = $row;
            //    $this->rowCount++;
            // }
         }

         $this->get_instance();
      } catch (\PDOException $e) {
         die("Error: " . $e->getMessage() . "<br/>");
      }

      return $this;
   }
543938
public function setFetchmode($mode)
    {
        if (is_numeric($mode)) {
            $this->fetchMode = (int) $mode;
        } else {
            if (defined($mode)) {
                $this->fetchMode = constant($mode);
            } else {
                throw new BuildException("Invalid PDO fetch mode specified: " . $mode, $this->getLocation());
            }
        }
    }
845704
public function setFetchMode($fetchmode = null)
    {
        $fetchmode = isset($fetchmode)
            ? $fetchmode
            : $this->options['fetch_mode'];

        $this->stmt->setFetchMode($fetchmode);
    }
1194975
public function paginate($rows = 0, $start = 0, $condition = '', $order='', $fields = '*', $fetchMode=PDO::FETCH_ASSOC) {
        $driver = $this->driver;
        is_array($condition) and $driver->where($condition[0],$condition[1]);
        $order and $driver->orderby($order);
        $driver->limit($rows,$start)->field($fields);
        return $driver->paginate($fetchMode);
    }
1178373
public function fetchAll($sql, $bind = [], $fetchMode = \PDO::FETCH_ASSOC, $useMaster = false)
    {
        $context = $this->_context;

        $context->sql = $sql;
        $context->bind = $bind;
        $context->affected_rows = 0;

        $this->eventsManager->fireEvent('db:beforeQuery', $this);

        if ($context->connection) {
            $type = null;
            $connection = $context->connection;
        } else {
            $type = $this->_has_slave ? 'slave' : 'default';
            $connection = $this->poolManager->pop($this, $this->_timeout, $type);
        }

        try {
            $start_time = microtime(true);
            $result = $connection->query($sql, $bind, $fetchMode, $useMaster);
            $elapsed = round(microtime(true) - $start_time, 3);
        } finally {
            if ($type) {
                $this->poolManager->push($this, $connection, $type);
            }
        }

        $count = $context->affected_rows = count($result);

        $event_data = compact('elapsed', 'count', 'sql', 'bind', 'result');

        $this->logger->debug($event_data, 'db.query');

        $this->eventsManager->fireEvent('db:afterQuery', $this, $event_data);

        return $result;
    }
32241
public function find($table, $fields = null, $where = null, $order = null, $limit = null, $offset = null, $array = array(), $fetchMode = \PDO::FETCH_ASSOC)
     {
         $sql = ' SELECT '.(($fields) ?? '*').' FROM '.(($table)).(($where) ? ' WHERE '.$where : ' ')
            .(($limit) ? ' LIMIT '.$limit : ' ')
            .(($offset && $limit) ? ' OFFSET '.$offset : ' ')
            .(($order) ? ' ORDER BY '.$order : ' ');

         $stmt = $this->conn->prepare($sql);

         foreach ($array as $key => $values) {
             return  $stmt->bindValue("$key", $values);
         }
         $stmt->execute();

         do {
             return $stmt->fetchAll($fetchMode);
         } while (
            $stmt->nextRowset());
         $stmt->close();
     }
943701
public function fetch($fetchMode = \PDO::FETCH_BOTH)
    {
        $fetchResult = $this->mysqliStatement->fetch();

        if ($fetchResult === false) {
            throw new MysqliException($this->mysqliStatement->error, $this->mysqliStatement->errno);
        }

        if ($fetchResult === null) {
            return;
        }

        $values = array();
        foreach ($this->result as $value) {
            $values[] = $value;
        }

        if ($fetchMode === null) {
            $fetchMode = $this->defaultFetchMode;
        }

        switch ($fetchMode) {
            case \PDO::FETCH_NUM:
                return $values;
            case \PDO::FETCH_ASSOC:
                return array_combine($this->resultFields, $values);
            case \PDO::FETCH_BOTH:
                $result = array_combine($this->resultFields, $values);
                $result += $values;

                return $result;
            default:
                throw MysqliException::fetchModeNotSupported($fetchMode);
        }
    }