开发者

Symfony inner join

How do we write an inner join query in symfony?

$tagQuery = Do开发者_如何学JAVActrine_Query::create()
            ->from('SfTagging t')
            ->innerjoin('t.Link L ON t.taggable_id=L.id');

echo $tagQuery->getSqlQuery();


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();


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜