huzefam
huzefam

Reputation: 1191

Symfony inner join

How do we write an inner join query in symfony?

$tagQuery = Doctrine_Query::create()
            ->from('SfTagging t')
            ->innerjoin('t.Link L ON t.taggable_id=L.id');

echo $tagQuery->getSqlQuery();

Upvotes: 0

Views: 1673

Answers (2)

Tom
Tom

Reputation: 30698

$tagQuery = Doctrine_Query::create()    
  ->from('SfTagging t')
  ->innerJoin('t.Link l');
echo $tagQuery->getSqlQuery();

Upvotes: 0

greg0ire
greg0ire

Reputation: 23255

You don't need to specify the ON part, doctrine already knows how to make the join if your schema is not too bad. I'd write it like this:

$tagQuery = SfTaggingTable::getInstance()
  ->createQuery('t')
    ->innerJoin('t.Link');
echo $tagQuery->getSqlQuery();

Upvotes: 1

Related Questions