繁体   English   中英

如何使用3个或更多表进行Propel查询?

[英]How do I do a Propel query with 3 tables or more?

我想做这个:

    SELECT * FROM `mydb`.`table1`
        INNER JOIN `mydb`.`table2`
            ON `table2`.`table1_id` = `table1`.`id`
        INNER JOIN `mydb`.`table3`
            ON `table3`.`id` = `table1`.`table3_id`
        WHERE `table2`.`myfield2`='string1'
        AND `table3`.`myfield3` = 'string2';

在Propel上查询,但找不到正确的方法。 只有两个表join()似乎工作得很好

$query = Table1Query::create()
            ->join('Table2')
            ->where('Table2.myfield2 = ?',  $string1)
            ->filterByMyfield3($string2)
            ->findOne(); 

但它如何与三个或更多表一起使用?

当然有可能。 您已在配置文件中描述了映射。 示例:

 $review = ReviewQuery::create() ->joinWith('Review.Book') ->joinWith('Book.Author') ->joinWith('Book.Publisher') ->findOne(); $book = $review->getBook() $author = $book->getAuthor(); $publisher = $book->getPublisher(); 

http://propelorm.org/documentation/04-relationships.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM