PHP代码:主义的DBAL查询生成器omitts一些加入
$xCodesQueryBuilder = $conn->createQueryBuilder();
$xCodesQueryBuilder->select("l.id","mdsh.xcode","mdso.xcode")
->from("location_tree","l")
->join("l","location_tree_pos","p","l.id = p.tree_id")
->rightJoin("l","hotel","h","h.location_id = l.id")
->leftJoin("l","offer_location","ol","l.id=ol.location_id")
->leftJoin("ol","mds_offer","mdso","ol.offer_id = mdso.offer_id")
->leftJoin("h","mds_hotel","mdsh","h.id = mdsh.hotel_id")
->where("p.parent_id IN (:ids)")
->andWhere("(mdso.xcode IS NOT NULL OR mdsh.xcode IS NOT NULL)");
var_dump($xCodesQueryBuilder->getSQL());exit;
结果:
SELECT l.id, mdsh.xcode, mdso.xcode
FROM location_tree l
INNER JOIN location_tree_pos p ON l.id = p.tree_id
RIGHT JOIN hotel h ON h.location_id = l.id
LEFT JOIN offer_location ol ON l.id=ol.location_id
WHERE (p.parent_id IN (:ids))
AND ((mdso.xcode IS NOT NULL OR mdsh.xcode IS NOT NULL))
任何想法,为什么最后2个连接被省略?
一些reaseon每个第一个参数加入必须是相同的(“L”的我的情况),然后它的工作。任何人都可以解释这背后的逻辑吗? – Itako
我有同样的问题。只有那些与“FROM”表别名关联的连接才会出现。其他一切似乎都被省略了。 – anushr