0

我正在尝试使用 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();
4

1 回答 1

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));
}
于 2013-10-04T07:01:03.723 回答