开发者

how to translate this query into Criteria?

I try to translate thi开发者_StackOverflow中文版s query into Criteria (with Propel), but without success.

Can you help me please ?

SELECT DISTINCT (email)
FROM user, travail
WHERE travail.id_user = user.id_user
AND id_site = "1"
AND `droits` = "1"

This my Criteria query :

  $c = new Criteria();
  $c->add(self::DROITS, 1, Criteria::EQUAL);
  $c->add(TravailPeer::ID_SITE, 1, CRITERIA::EQUAL);
  $c->setDistinct(self::EMAIL);


How about this:

$c = new Criteria();
$c->add(UserPeer::DROITS, 1);
$c->addJoin(UserPeer::ID_USER, TravailPeer::ID_USER);
$c->add(TravailPeer::ID_SITE, 1);
$c->clearSelectColumns();
$c->addSelectColumn(UserPeer::EMAIL);
$c->setDistinct();

$rs = UserPeer::doSelectRS($c);


Hi You can use propel builder to translate not only this but any sql to the criteria. following is one of the online builder site.

http://propel.jondh.me.uk/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜