joinWith('articleClass');"; then call the createComment and getSql methods; finally print it out through "var_dump"."/> joinWith('articleClass');"; then call the createComment and getSql methods; finally print it out through "var_dump".">
Home >PHP Framework >YII >How to print sql in yii2
yii2 method of printing sql: first query the structure through the statement "Article::find()->joinWith('articleClass');"; then call the createComment and getSql methods; finally print it out through "var_dump" That’s it.
##YII2.0 printing sql statement method
//1、查询结构 $record = Article::find()->joinWith('articleClass'); //2、复制一下查询语句 $query = clone $record; //3、调用createComment()和getSql()方法 $sql = $query->createCommand()->getSql(); //4、打印出来 var_dump($sql);die();Recommended: "
yii tutorial"
The above is the detailed content of How to print sql in yii2. For more information, please follow other related articles on the PHP Chinese website!