多重加入 - 推进

时间:2011-09-01 02:22:57

标签: propel

我有一种地图表,我需要执行多个连接以获取其他必要的数据。你如何用Propel做到这一点?

Sql会是这样的:

SELECT * FROM table1 table1.col1 = table2.id上的INNER JOIN table2 table1.col2 = table3.id

上的INNER JOIN table3

1 个答案:

答案 0 :(得分:3)

我只是错误地阅读了他们的说明。

要做到这一点,你只需:

$result = ClassQuery::create()->joinWith('ClassTable.Instructor')->joinWith('Instructor.Department');

然后你做:

$instructor = $result->getInstructor();
$department = $instructor->getDepartment();

然后您可以通过getter访问属性:

$prop = $department->getName();
相关问题