soukupj
(Info)
1
How to logging only my custom query, without Active Record query … ?
$query = "
INSERT INTO example_contact
(name, email, subject, body, created, ip)
VALUES
(:name, :email, :subject, :body, now(), :ip)";
$command = Yii::app()->db->createCommand($query);
$command->bindParam(":name", $this->name, PDO::PARAM_STR);
$command->bindParam(":email", $this->email, PDO::PARAM_STR);
$command->bindParam(":subject", $this->subject, PDO::PARAM_STR);
$command->bindParam(":body", $this->body, PDO::PARAM_STR);
$command->bindParam(":ip", $ip, PDO::PARAM_STR);
$command->execute();
confing main.php
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
array(
// logging SQl queries:
'class' => 'CFileLogRoute',
'levels' => 'trace',
'categories' => 'system.db.CDbCommand',
),
),
),
THX
jayant
(Codesutras)
2
Well There is no such a good way to debug your sql queries in yii.Might be it is a proposed feature in Yii 2.0.
So,If you want to debug your queries then do it manually as much as you can. 