Return dataProvider SQL

I am doing something along the lines of

$SQL = "SELECT * FROM Deliveries WHERE (t1.`Incoming` BETWEEN :start_date AND :end_date)";
$params = [':start_date' => $startDT, ':end_date' => $EndDT];
$dataProvider = new SqlDataProvider([
	'sql' => $SQL,
	'pagination' => false,
	'params' => $params,
]);

How can I return the raw sql of the dataProvider with the params substituted in?

You can do something like Yii::$app->db->createCommand($SQL)->getRawSql(),
But why you wanna do this of this way?, why dont use the QueryObject of Yii2 to perform your queries(i suppose you want something specifically without model)

1 Like

It’s for debugging purposes only. This isn’t for production, just trying to troubleshoot something.

I was hoping there was a way directly with the $dataProvider, but using a separate createCommand works.

Thank you for your help.