Howtos

...Retrieve all objects not yet associated (in an has_many association with a join table)

The following exemple will retrieve all users which are not member of any group.


$user = new User();
$res = $user->execute('
  SELECT Users.* 
  FROM Users 
  LEFT OUTER JOIN Groups_Users 
    ON Groups_Users.user_id = Users.id 
  WHERE Groups_Users.id IS NULL');

$users = array();
while($row = mysql_fetch_assoc($res)){
  $user = new User();
  $user->fromArray($row);
  $users[] = $user;
}
print_r($users);
    

Open Source Object Relational Mapping in PHP

Download Porte 0.2.1