gpt4 book ai didi

php - Yii 关系子查询

转载 作者:行者123 更新时间:2023-11-29 10:47:34 25 4
gpt4 key购买 nike

这是我的查询:

select * from order_shipping_date osd inner join  
(SELECT MAX(osd.id) as id FROM order_shipping_date osd
group by osd.order_id) osdi ON osd.id = osdi.id

我可以保持这样,但希望可以将其定义为 relations

这样以后使用这样的代码更舒服这到底可行吗?我找不到任何例子。

最佳答案

Additional options可以在关系声明中指定。

public function relations()
{
return array(
'orderShippingDate' => array(
// define you relation
'join' => '(/* subquery here*/) osdi ON osdi.id=orderShippingDate.id',
'joinType' => 'INNER JOIN'
),
);
}

关于php - Yii 关系子查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44292317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com