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

array

posted by mungiu 9 years ago

How can i obtain an array of values not an array of object.


    $categorii = Categorii::getAll();
    fCOre::expose($categorii->getRecords());

There is no way to do that, mostly because that breaks the benefits of wrapping the rows of data into self-aware objects.

The simplest solution would be to:

$data = fORMDatabase::retrieve()->query("SELECT * FROM categorii");

This code would also be faster. If you need it to go through all of the processing with fActiveRecord, you could write a class like the following, and have your records extend it instead of fActiveRecord:

class TransparentRecord extends fActiveRecord {
    function pullValues() {
        return $this->values;
    }
}
class Categorii extends TransparentRecord { }

fCore::expose($categorii->call('pullData'));
posted by wbond 9 years ago

I want use an array of values for fill the form to edit record so if i want this must do: $item = new Texte(fRequest::get("id")); $var = Texte::pullArray(fRequest::get("id"));

Is't another solution to not loaded records two times for this?

posted by mungiu 9 years ago

Well, you don't need to load data from the database twice to encode it. With the code I showed above, you can do:

$record = new Categorii(fRequest::get('id'));
$values = $record->pullData();

Then you can use fHTML::encode() on the values in $values.

You other option is to use the built-in encode verb for columns in fActiveRecord objects. If you have a column named first_name, you can call $record->encodeFirstName() to encode the data.

posted by wbond 9 years ago