如何在 Yii 中保存之前检查 SQL 查询


how to check sql query before save in yii

我正在尝试使用 yii 模型在我的表中插入一条记录。它没有显示错误,但没有添加任何记录。现在我想在保存在 yii 中之前检查 sql 查询。有什么办法可以做到这一点吗?

这是我代码的一部分。

$form = new BaseSysRegistration();
$form->attributes = $_POST['BaseSysRegistration'];
$form->of_passport_number = $_POST['of_passport_number'];
$form->password2 = $_POST['BaseSysRegistration']['password'];
$form->email_addr = $_POST['BaseSysRegistration']['email_addr'];
$form->save();
$form = new BaseSysRegistration();
$form->attributes = $_POST['BaseSysRegistration'];
$form->of_passport_number = $_POST['of_passport_number'];
$form->password2 = $_POST['BaseSysRegistration']['password'];
$form->email_addr = $_POST['BaseSysRegistration']['email_addr'];
if ($form ->save(true)) { // Return if the model is saved. (With true validate the fields)
     Yii::app()->user->setFlash('success', 'All correct');
     $this->redirect(array('index'));
}else{
     Yii::app()->user->setFlash('error', 'Error');
     $this->redirect(array('update', 'model' => $form));
}