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 DataObjectCursor returns an object you access via object syntax (ie. $object->field), vs array syntax ($array['field']) for the ArrayCursor

public PHPFUI\ORM\BaseCursor::__construct(?PDOStatement $statement = NULL, array $input = [])
  • param array $input
public PHPFUI\ORM\BaseCursor::__destruct()
public PHPFUI\ORM\BaseCursor::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 current() : ?mixed
  • return mixed representation of the current row
public PHPFUI\ORM\BaseCursor::key() : int

The offset of the row in the query, 0 based

public next() : void

Go to the next record

public PHPFUI\ORM\BaseCursor::rewind() : void

Reset the cursor to the beginning of the set

public PHPFUI\ORM\BaseCursor::setCountSQL(string $limitedSql) : static

Sets the count when a limit clause is used.

public PHPFUI\ORM\BaseCursor::setQueryCount(int $count) : self
public PHPFUI\ORM\BaseCursor::setTotalCountSQL(string $totalSql) : static

Sets the count for the full query with no limit clause

public PHPFUI\ORM\BaseCursor::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 valid() : bool

Returns true if not at the end of the input

protected ?int PHPFUI\ORM\BaseCursor::$index = NULL
protected readonly array PHPFUI\ORM\BaseCursor::$input
protected ?PDOStatement PHPFUI\ORM\BaseCursor::$statement
protected PHPFUI\ORM\BaseCursor::init() : void

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

private array $current
  • var array<string,string>
© 2024 Bruce Wells
Search Namespaces \ Classes