推进和离开 [英] Propel and leftJoin

查看:118
本文介绍了推进和离开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Doctrine我可以:

In Doctrine i can:

    $q = Doctrine_Query::create()
        ->from('One o')
        ->where('t.text = ?', 'aaa')
        ->andWhere('h.text = ?', 'bbb')
        ->leftJoin('o.Two t')
        ->leftJoin('t.Three h')
        ->leftJoin('h.Four f')
        ->execute();

如何在Symfony 1的Propel中进行此操作?

How can i make this in Propel from Symfony 1?

推荐答案

如果您在1.6之前使用propel ,则必须遵循

知道每个关系的主要关键。
如果它是 id ,它可以是这样的:

You have to know the primary key for each relation. If it's id, it can be something like that:

$c = new Criteria();

$c->add(TwoPeer::TEXT, 'aaa');
$c->add(ThreePeer::TEXT, 'bbb');

$c->addJoin(OnePeer::TWO_ID, TwoPeer::ID, Criteria::LEFT_JOIN);
$c->addJoin(TwoPeer::THREE_ID, ThreePeer::ID, Criteria::LEFT_JOIN);
$c->addJoin(ThreePeer::FOUR_ID, FourPeer::ID, Criteria::LEFT_JOIN);

$results = OnePeer::doSelect($c);

对于Propel 1.6 (使用 https://github.com/propelorm/sfPropelORMPlugin ),如下所示:

For Propel 1.6 (use it from https://github.com/propelorm/sfPropelORMPlugin), something like that:

$results = OneQuery::create()
  ->useTwoQuery()
    ->filterByText('aaa')
    ->useThreeQuery()
      ->filterByText('bbb')
    ->endUse()
  ->endUse()
  ->leftJoinWith('Three.Four')
  ->find();

这篇关于推进和离开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆