Propel-多次连接同一张表并分组 [英] Propel - Joining the same table multiple times and grouping
本文介绍了Propel-多次连接同一张表并分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用Propel编写报告,需要多次连接同一张表,以便使用相同的数据获取不同日期范围内的不同统计信息.
I'm writing a report with Propel and need to join the same table multiple times in order to get different stats for different date ranges using the same data.
问题似乎在于,推进会忽略查询中的多个->leftJoin()
调用.我认为我需要为每个连接添加别名,以便可以对它们进行单独处理,但是我找不到解决方法.
The issue appears to be that propel ignores multiple ->leftJoin()
calls on a query. I think I need to alias each join so they can be treated individually but I can't find a way to do that.
推荐答案
尝试addJoin()
Try addJoin()
$c = new Criteria();
$c->addJoin(array(Table1Peer::ID,), array(Table2Peer::Table1Peer_ID,), Criteria::LEFT_JOIN);
您也可以使用别名:
$c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
具有别名和传递数组的功能,看来您应该能够对同一张表进行多次联接.
With the ability to alias and pass in arrays it seems you should be able to do multi-joins to the same table.
这篇关于Propel-多次连接同一张表并分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文