yii2 直接输出model的(active record)sql语句

来源:互联网 发布:mac机中钉钉无法登陆 编辑:程序博客网 时间:2024/05/02 01:40

得到yii2模型的sql输出


[html] view plain copy print?
  1. $query = Salesorder::find()  
  2.   ->where(['order_id'=>[1,2,3,4]])  
  3.   ->select(['order_id'])  
  4. ;  
  5. // get the AR raw sql in YII2  
  6. $commandQuery = clone $query;  
  7. echo $commandQuery->createCommand()->getRawSql();  
  8. exit;  



[html] view plain copy print?
  1. echo  Salesorder::find()  
  2.   ->where(['order_id'=>[1,2,3,4]])  
  3.   ->select(['order_id'])  
  4.  ->createCommand()->getRawSql();
0 0