PlDBTableEntry: add support for custom selection.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 31 Oct 2010 21:29:45 +0000 (22:29 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 31 Oct 2010 21:39:12 +0000 (22:39 +0100)
commit71db9fda290b6d43e2545615756d6dea6c630c84
treefd8ed0827d9ee74c938f1b54f8efa8b641085c51
parent200302483321518dee3ef9df125e6f968102ecd8
PlDBTableEntry: add support for custom selection.

Selection based on a non-primary key is now possible.
 $user = new PlDBTableEntry('accounts');
 $user->uid = 26071;
 $user->fetch(); /* selection on primary key */

 $user = new PlDBTableEntry('accounts');
 $user->hruid = 'florent.bruneau.2003';
 $user->fetch(); /* selection on non-primary unique key */

This also works for multiple keys in case of iteration
  $selector = new PlDBTableEntry('accounts');
  $selector->type = 'ax';
  foreach ($selector as $user) {
     $user->comment = 'AX secretary';
     $user->update();
  }

PlDBTableEntry now expose iterateOnCondition that takes a custom condition
for the entry selection.
  $selector = new PlDBTableEntry('accounts');
  $it = $selector->iterateOnCondition('FIND_IN_SET(\'watch\', flags');
  while ($user = $it->next()) {
    $user->comment = 'Watched account';
    $user->update();
  }

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/pldbtableentry.php