-2
如何在另一個表中插入名字在這裏我的代碼在客戶表中插入數據,但我想在另一個表中插入firstname。 我的代碼註冊成功。如何在數據庫的另一個表中插入firstname?
public function actionRegister() {
$model = new Customer('signup');
if (Yii::app()->request->getPost('Customer')) {
$custoerary = Yii::app()->request->getPost('Customer');
$model->attributes = $custoerary;
$model->_active = 1;
$model->last_visted = date('Y-m-d H:i:s');
$model->date_added = date('Y-m-d H:i:s');
$model->store_id = $this->store_id;
if ($model->validate()) {
$model->password = md5($custoerary['password']);
$model->confirmpassword = md5($custoerary['confirmpassword']);
if ($model->save()) {
$selectmode = Customer::model()->find("store_id='" . $this->store_id . "' and email='" . $model->email . "' and password='" . md5($custoerary['password']) . "' ");
if (count($selectmode) != 0) {
Yii::app()->session['customer'] = $selectmode->id;
if (isset($_GET['redirect'])) {
$this->redirect(urldecode($_GET['redirect']));
}
$this->redirect('./');
} else {
$error = "Connection Error! Try again Later";
}
} else {
$error = CHtml::errorSummary($model);
}
} else {
$error = "Emailid already Exists!";
}
}
if ($this->session_id != 0) {
if (isset($_GET['redirect'])) {
$this->redirect(urldecode($_GET['redirect']));
}
$this->redirect('./');
}
$this->render('signup', array('error' => $error, 'facebookurl' => $loginUrlFacebook, 'googleurl' => $loginUrlGoogle, 'model' => $model, 'model_advertisement' => $model_advertisement, 'model_slider' => $model_slider, 'model_product' => $model_product, 'model_category' => $model_category, 'model_brand' => $model_brand), false, true);
}
我想當客戶註冊成功,當時名字將插入另一個表中。如何?
好的,但我在哪裏寫這段代碼? –
我已更新答案 – scaisEdge
註冊成功,但沒有存儲數據 –