0 follower

Final Class Yiisoft\Db\Query\BatchQueryResult

InheritanceYiisoft\Db\Query\BatchQueryResult
ImplementsYiisoft\Db\Query\BatchQueryResultInterface

Represents the result of a batch query execution.

A batch query is a group of many SQL statements that are executed together as a single unit.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\Db\Query\QueryInterface $query )
$query Yiisoft\Db\Query\QueryInterface

                public function __construct(private readonly QueryInterface $query) {}

            
batchSize() public method

public Yiisoft\Db\Query\BatchQueryResult batchSize ( integer $value )
$value integer

                public function batchSize(int $value): static
{
    $this->batchSize = $value;
    return $this;
}

            
current() public method

public array current ( )

                public function current(): array
{
    if ($this->index === -1) {
        $this->next();
    }
    return $this->batch;
}

            
getBatchSize() public method

public integer getBatchSize ( )

                public function getBatchSize(): int
{
    return $this->batchSize;
}

            
getQuery() public method

public Yiisoft\Db\Query\QueryInterface getQuery ( )

                public function getQuery(): QueryInterface
{
    return $this->query;
}

            
indexBy() public method

public Yiisoft\Db\Query\BatchQueryResult indexBy ( Closure|string|null $indexBy )
$indexBy Closure|string|null

                public function indexBy(Closure|string|null $indexBy): static
{
    $this->indexBy = $indexBy;
    return $this;
}

            
key() public method

public integer key ( )

                public function key(): int
{
    if ($this->index === -1) {
        $this->next();
    }
    return $this->index;
}

            
next() public method

public void next ( )

                public function next(): void
{
    $this->batch = $this->fetchData();
    ++$this->index;
}

            
resultCallback() public method

public Yiisoft\Db\Query\BatchQueryResult resultCallback ( Closure|null $callback )
$callback Closure|null

                public function resultCallback(?Closure $callback): static
{
    $this->resultCallback = $callback;
    return $this;
}

            
rewind() public method

public void rewind ( )

                public function rewind(): void
{
    if ($this->index === 0) {
        return;
    }
    $this->dataReader = null;
    $this->batch = $this->fetchData();
    $this->index = 0;
}

            
valid() public method

public boolean valid ( )

                public function valid(): bool
{
    if ($this->index === -1) {
        $this->next();
    }
    return !empty($this->batch);
}