User Tools

Site Tools





Fetch records

There are a couple of methods to fetch TableRecords from a Table. Which method to use depends on which information is available and the quantity of records to fetch.

To fetch one TableRecord from a Table when having the UUID for the wanted TableRecord, simply use

$tr = TableRecordFactory::getTableRecord( $uuid );

This fetches the TableRecord with the given uuid from the TableRecordFactory.

If you have certain criteria to apply and want to fetch a limited subset of a Table based on that criteria, a filter can be used to fetch the data, as follows

$filter = new Filter();
$filter->addRule( $tableName, $fieldName, $operand, $value, $andor );
$filter->getTableRecords( $tableName );

for more information about filters, see Filters.

If you want to fetch a great number of TableRecords from the Table, with certain criteria or perhaps you want to fetch all the TableRecords in the table the getRecordsIdentifier is the preferred way to go. Since the Vortex caches all TableRecords loaded from the database you might need to clear the TableRecordFactory cache to prevent out of memory exceptions when loading vast numbers of TableRecords.

$filter = new Filter();
$table = TableFactory::getTableFromName( 'myTable' );
$resultSet = $table->getRecordsIdentifier( $filter );
$cnt = 0;
while( $tr = $table->getRecordsNext( $resultSet ) ){
  echo( $tr->get( 'myField' );
  if( $cnt++ % 100 == 0 ) TableRecordFactory::clear();

To get the number of rows matching a given set of Filter and SearchString getRecordsCount is the method to use:

$cnt = $table->getRecordsCount( $filter, "[myfield=test]" );
vortex/api/table.txt · Last modified: 2019/06/28 07:00 by hubbe