/* sfPropelFinder::join() with multiple self-referenced foreign keys */ /*********************************************************************/ $t->diag('sfPropelFinder::join() with multiple self-referenced foreign keys'); HumanPeer::doDeleteAll(); $human1 = new Human(); $human1->setName('John'); $human1->save(); $human2 = new Human(); $human2->setName('Jane'); $human2->save(); $human3 = new Human(); $human3->setName('Albert'); $human3->setHumanRelatedByFatherId($human1); $human3->setHumanRelatedByMotherId($human2); $human3->save(); $finder = sfPropelFinder::from('Human')-> join('Human father', 'Human.FatherId', 'father.Id', 'INNER JOIN')-> join('Human mother', 'Human.MotherId', 'mother.Id', 'INNER JOIN')-> where('father.Name', 'John')-> where('mother.Name', 'Jane'); $nbHumans = $finder->count(); $t->is($nbHumans, 1, 'join() allows to join to the current table with several foreign keys using an alias'); $t->is($finder->getLatestQuery(), propel_sql('SELECT COUNT([P13*][P12human.ID]) FROM human INNER JOIN human father ON (human.FATHER_ID=father.ID) INNER JOIN human mother ON (human.MOTHER_ID=mother.ID) WHERE (father.NAME=\'John\' AND mother.NAME=\'Jane\')'), 'join() uses aliased table names when using an alias relation'); HumanPeer::doDeleteAll(); $human1 = new Human(); $human1->setName('John'); $human1->save();