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