如何在Yii2中将此Mysql查询转换为活动记录查询

时间:2017-11-20 10:49:16

标签: yii2 mysql-workbench

Select * 
from po_table 
WHERE sender_uid = "User Input" and po_no IN (
   Select po_no WHERE receiver_uid = login_rec_uid
);

1 个答案:

答案 0 :(得分:0)

尝试使用activeRecord类中的find()

e.x:

$ senderid = Sender :: find() - > where(['id'=> $ userInputID]) - > one();

来源:http://www.yiiframework.com/doc-2.0/yii-db-baseactiverecord.html#findOne()-detail