All pastes #835029 Raw Edit

Unnamed

public text v1 · immutable
#835029 ·published 2007-12-28 17:21 UTC
rendered paste body
I have some problems when using left join.

Here 2 tables:

Table A:
  id: integer autoIncrement primaryKey
  b_id : FOREIGN KEY, linked to id table B field. VERY IMPORTANT: b_id CAN BE NULL
  name: string

Table B:
  id: integer autoIncrement primaryKey
  name: string



With this command:
  $result = APeer::doSelectJoinB(new Criteria());
I only get the objects from A where b_id field IS NOT NULL

With those commands :
  $c = new Criteria();
  $c->AddJoin(APeer::B_ID, BPeer::ID, Criteria::LEFT_JOIN);
  $result = APeer::doSelect($c);
I got all objects from A, this is fine. But objects from B are not "hydrated".
With a Table A object from this result, when I execute "$a->getB()", a new request is launched to read the corresponding B object in the database. And I don't want this because i have tons of "$a->getB()" to execute.

Isn't exists an action who could be like "doSelectLEFTJoinB(...)", that get all objects from both tables, and who hydrate them, whith a left join ?