Copied!

A Cursor does not read the entire query result into memory at once, but will just read and return one row at a time.

Since it is iterable, it can be used in a foreach statement. The index or key will be an integer starting at 0 for the first record returned.

Abstract
Methods
public __construct(?PDOStatement $statement = NULL, array $input = [])
 
  • param array $input
public __destruct()
public count() : int
 

count is the actual number of records returned by the query, which should less than or equal to the limit clause if it was used.

See total to get the number of records in the table without a limit clause.

public abstract current() : ?mixed
 
  • return mixed representation of the current row
public key() : int
 

The offset of the row in the query, 0 based

public abstract next() : void
 

Go to the next record

public rewind() : void
 

Reset the cursor to the beginning of the set

public setCountSQL(string $limitedSql) : static
 

Sets the count when a limit clause is used.

public setQueryCount(int $count) : self
public setTotalCountSQL(string $totalSql) : static
 

Sets the count for the full query with no limit clause

public total() : int
 

Returns the total number records returned in the query without a limit clause

See count if you need the number of records the query returned.

public abstract valid() : bool
 

Returns true if not at the end of the input

Properties
protected ?int $index = NULL
protected readonly array $input
protected ?PDOStatement $statement
Methods
protected init() : void
 

Internal method to make sure rewind is called before anything else but will save the query if never executed.

Properties
private ?int $count = NULL
private ?PDOStatement $countStatement = NULL
private ?int $total = NULL
private ?PDOStatement $totalStatement = NULL
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration