Yii2 - get query from ActiveRecord

voted: 1
php framework yii2 activerecord

For get query from ActiveRecord:

// don't use ->all() nor ->one() to not execute query:
$activeRecordExpression = Model::find();
$query = $activeRecordExpression->prepare(Yii::$app->db->queryBuilder)->createCommand()->rawSql;
//then echo it or do something with it
working url: not entered
version: 2 and maybe others
Leave a Comment:
Characters left:
No comments yet.