DBCreator
(DBCreator)
February 13, 2020, 8:58pm
1
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?
jmar1998
(Heartnet)
February 14, 2020, 12:05am
2
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
DBCreator
(DBCreator)
February 14, 2020, 4:20pm
3
jmar1998:
->getRawSql()
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.