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

IndividualRecords, getRecord()

posted by carlton 8 years ago

Hi there I get stuck with http://flourishlib.com/docs/fRecordSet#IndividualRecords

How to get the return "false", if there is no record to fetch. I don't understand how to use fNoRemainingException. Thanx.

public function getPage($page_id)
        {
                $result = fRecordSet::build(
                                __CLASS__,
                                array('page_id=' => (int)$page_id)
                                )->getRecord(0);
                //fCore::expose($result);
                if($result){
                       // Some actions 
                }  else {
                    return false;
                }
        }

Flourish uses exceptions to force developers to handle conditions that will normally result in unintended behavior. Exceptions are also powerful in that they allow handling of an error condition in parent scopes without each level having to know all valid child function/method return values.

But you didn't really ask why, so here is how to turn an exception into false:

try {
    return $record_set->getRecord(0);
} catch (fNoRemainingException $e) {
    return FALSE;
}
posted by wbond 8 years ago

Great. Thanks! This is the easy way when you use the exception. Now I understand everything.

posted by carlton 8 years ago