Prado\Data\ActiveRecord\TActiveRecord::fetchResultsFor PHP Method

fetchResultsFor() protected method

This method can be used to lazy load relationships. class TeamRecord extends TActiveRecord { ... private $_players; public static $RELATION=array ( 'players' => array(self::HAS_MANY, 'PlayerRecord'), ); public function setPlayers($array) { $this->_players=$array; } public function getPlayers() { if($this->_players===null) $this->fetchResultsFor('players'); return $this->_players; } } Usage example: $team = TeamRecord::finder()->findByPk(1); var_dump($team->players); //uses lazy load to fetch 'players' relation
Since: 3.1.2
protected fetchResultsFor ( $property ) : boolean
return boolean true if relationship exists, false otherwise.
    protected function fetchResultsFor($property)
    {
        if (($context = $this->createRelationContext($property)) !== null) {
            return $context->getRelationHandler()->fetchResultsInto($this);
        } else {
            return false;
        }
    }