Works like select() but for getRelationship() calls
@param String $linkName
@param String $field
@param String $alias
@param Boolean $only
@param Boolean $override
@return PhpBURN_Core
Params
$linkName
Is the name of the relationship that will receive the commands
$condition
The SELECT condition, for example: “COUNT(id_users)” or “name”
$alias
The alias to be outputed to the model example: “total” or “full_name”
$only (deprecated)
$override (optional)
Optional field that clean all select() used before and starts again.
Explanation
Sometimes you need to use a function or even give another name for that field you mapped, well, now you can EASY EASY…
Let’s see how to use a function to COUNT the registers for example:
$user = new Users(); $user->get(1); $user->relationshipSelect('COUNT(id_albums)','total'); $user->groupBy('id_albums'); $totalLines = $user->getRelationship('albums); print $user->albums->fetch()->total;
Note that $totalLines is different from total, in $totalLines in this case will return 1 while $user->albums->total will return the amount of items in the table.