void getActiveRecordsClass( string $class, string $tableName, optional string $where=false, optional mixed[] $bindarr=false, optional mixed[] $primaryKeyArray=false, optional mixed[] $queryExtras=array(), optional mixed[] $relationsData=array() )
This allows you to retrieve an array of objects derived from ADOdb_Active_Records. Returns false if an error occurs.
This string represents the class of the current active record
Table used by the active record object
Where, order, by clause
For more information on the use of Bind
variables, see execute
Query extras: limit, offset…
class Product extends ADOdb_Active_Record{}; $table = 'products'; $whereOrderBy = "name LIKE 'A%' ORDER BY Name"; $activeRecArr = $db->getActiveRecordsClass('Product', $table, $whereOrderBy); /* * the objects in $activeRecArr are of class 'Product' */ foreach($activeRecArr as $rec) { $rec->id = rand(); $rec->save(); }
To use bind variables (assuming ? is the place-holder for your database):
$activeRecArr = $db->getActiveRecordsClass($className,$tableName, 'name LIKE ?', array('A%')); /* * You can also define the primary keys of the table by passing an array of field names: */ $activeRecArr = $db->getActiveRecordsClass($className,$tableName, 'name LIKE ?', array('A%'), array('id'));