Works like $model->find() but instead it search ofr a mapped relationship.
Generate a SELECT into the relationship.
@param String $name
@param Boolean $fluid
@param Array $options
@return Mixed ( Integer/PhpBURN_Core )
Params
$name
The name of mapped relationship defined by $model->getMap()->addRelationship().
$fluid
Boolean param to work with FLUID INTERFACE that means intead return the affected rows it will return the same model
$options
Array of options to getRelationship ( we do not recommend this, instead use relationship*() methods )
Explanation
This method works just like find() but has differents params here we have a mandatory param called $name, without this you can’t tell the system wich mapped relationship you’re looking for.
It returns two different things. If you do not specify $fluid = true it will return the number of affected rows but if you do it will work with FLUID INTERFACE and returns Model/PhpBURN_Core instead.
To learn how to create relationships see addRelationship() in Documentation at www.phpburn.com.
Default usage
$user = new Users();
$user->getRelationship('albums');
while($user->albums->fetch()) {
print_r($user->albums->toArray());
}
Once called the relationship it will create an attribute in your model with the SAME NAME of the relationship working like a PhpBURN Model, that means it is recursively and you can have how many relationships you want.
It will work no more like a ENTITY ORIENTED database but like a OBJECT ORIENTED database or ( document oriented )
For example:
$user = new Users();
$user->getRelationship('albums');
while($user->albums->fetch()) {
$user->albums->getRelationship('pictures');
while( $user->albums->pictures->fetch() ) {
$user->albums->pictures->getRelationship('comments');
while($user->albums->pictures->comments->fetch()) {
...
}
}
}
You can also use FLUID INTERFACE doing:
$user = new Users();
$user->getRelationship('albums',true)
->fetch();
