I am trying to insert a record in my table using yii model. It shows no error but no record is being added. Now I want to check the sql query before save in yii. Is there any way i can do that?
Here is a part of my code.
$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));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.