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

How to print sql in yii2

藏色散人
藏色散人Original
2020-07-21 10:40:133486browse

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.

How to print sql in yii2

##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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn