Is there an easy way to construct a dataprovider that returns objects related to another object?
I'm basically looking for the simplest version of this function:
I do not want to return an array of related objects. Some instances may have thousands of related objects and I'm concerned about performance issues. (Sidenote: is that a valid concern? Should I just use CArrayDataProvider?)
I have considered this solution but it seems somewhat complicated:
I'd like to avoid that if possible. Any ideas/patterns for solving this problem?
I'm basically looking for the simplest version of this function:
/** * @param CActiveRecord $model The primary model whose relations the provider will retrieve * @param string $relationName The name of the relation we want to retrieve * @return CActiveDataProvider Provider that returns the related models **/ public function getRelationProvider($model, $relationName);
I do not want to return an array of related objects. Some instances may have thousands of related objects and I'm concerned about performance issues. (Sidenote: is that a valid concern? Should I just use CArrayDataProvider?)
I have considered this solution but it seems somewhat complicated:
- Parse the relation declaration into a criteria object
- Merge that criteria with the DbCriteria of an instance of the related model
- Construct a dataprovider using the updated instance
I'd like to avoid that if possible. Any ideas/patterns for solving this problem?