I'm new to Doctrine and ActiveRecord.
How should I filter a table after it has been loaded? (i suppose this is preferred over sending multiple queries?)
Is this 'good' or 'bad'?
class UserTable extends Doctrine_Table {
function filterByGroup($group) {
$ut = new UserTable();
foreach($this as $u) {
if($u->group == $group) $ut->add($u);
}
return $ut;
}
}
Edit:
I understand there are built-in functions which provider 'filtering' functionality. But will the two following code-blocks perform differently regarding performance?
//1
$users = Doctrine_Core::getTable('Users')->findAll();
$admins = Doctrine_Core::getTable('Users')->findByGroupName('admin');
//2
$admins = Doctrine_Core::getTable('Users')->findByGroupName('admin');
$users = Doctrine_Core::getTable('Users')->findAll();