Skip to content

Add Methods that use PDOStatement fetch & Generators #27

@rotexdegba

Description

@rotexdegba

Add methods to the Model class that return a Generator that yields either an assoc arrays or a records. These methods will not be able to eager load related data because they are streaming

  • streamRows(?\Aura\SqlQuery\Common\Select $select_obj=null): Generator
  • streamRecords(?\Aura\SqlQuery\Common\Select $select_obj=null): Generator

The Generator returned will yield a row (assoc array representing a row in the desired DB table) or a record object (representing a row in the desired DB table) on each loop iteration.

These new methods will use minimal & constant memory, but will most likely run not a fast as their fetch(Rows|Records)Into(Array|Collection) counterparts that use more memory as the number of records or rows to be fetched increases but run faster than these two new methods.

They would be very useful for long running applications with large data sets that are to be run in the background. They will be useful where you want to sequentially loop through all rows or records from a DB table with lots of data and you are running on a memory constrained machine.

Metadata

Metadata

Assignees

Labels

nice-to-haveFeatures or enhancements that are not pressing but nice to have

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions