$users = new User();
$users->where_related('group', 'name', 'Administrator')->get();
// Loop over all administrators
foreach($users->all as $u) {
// do stuff
}
After:
Code:
$users = new User();
$users->where_related('group', 'name', 'Administrator')->get();
// Loop over all administrators
foreach($users as $u) { // <--- This line here!
// do stuff
}
As you can see, it's a little easier to read, and one less "gotchya" type of mistake. It's especially nice with the 1.4.0 ability to seamlessly use (standard) plural relationship names:
Code:
// assume we know the group ID we want:
$group = new Group($group_id);
$group->users->get();
foreach($group->users as $u) {
// do stuff
}
One caveat:
This completely breaks the (rarely-used) ability to do this:
Code:
foreach($user as $k => $f) {
echo("user->$k = $f\n");
}
If I find that this is breaking a lot of existing code, I might pull it. If it only breaks a little, I have a workaround. If it doesn't break any, I'm leaving it as is.[/quote]
Thank you man !!
Great stuff !!! One less detail to get us stucked !