Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

fRecordSet -> toArray()

posted by anonymous 8 years ago

is it possible to convert a recrodset or activerecord to an array?

$array = $records->toArray();

There are areas in my code where I use unbufferedQuery which returns records as an array and then in another controller I build records from fActiveRecord and I need to treat the results the same way rather then writing code to check if it is an array type or instance of recordset.

This would be a great feature for this little framework.

class TransparentRecords extends fActiveRecord {

//put your code here function pullValues($field) { return $this->values[$field]; }

function pullAllValues() { return $this->values; }

}

posted by mungiu 8 years ago

fRecordSet implements Iterator so it's accessible like an array (the keys are only numeric).

$record = fRecordSet::build('className');
//$record[0] -> fActiveRecord object
//$record[1] -> fActiveRecord object

Also you can use foreach of course (or for ($i = 0; $i < $record->count(); $i++)).

Are you looking to have each $record be the (protected) values and not have to use get*()?

posted by audvare 8 years ago