doudao9915 2013-10-29 16:03
浏览 18
已采纳

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

I want to do this:

    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';

query on Propel, but can't find the right way to do it. With only two tables join() seems to work fine like this

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

But how does it work with three or more tables?

  • 写回答

1条回答 默认 最新

  • duanfan1869 2013-10-29 16:18
    关注

    Of course it is possible. You have described the mapping in a config file. Example :

    $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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用
  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题