如何在yii中保存之前检查sql查询

时间:2013-10-04 06:43:13

标签: php mysql sql sql-server 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();

1 个答案:

答案 0 :(得分:0)

$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));
}