本文整理汇总了PHP中Reg::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Reg::save方法的具体用法?PHP Reg::save怎么用?PHP Reg::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reg
的用法示例。
在下文中一共展示了Reg::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Reg();
if (isset($_POST['Reg'])) {
$model->attributes = $_POST['Reg'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例2: actionBlank
public function actionBlank($id)
{
$event = Event::model()->findByPk($id);
if (Yii::app()->request->isAjaxRequest) {
$data = Yii::app()->request->getParam('data');
$reg = new Reg();
$reg->user_id = Yii::app()->user->getId();
$reg->event_id = $event->id;
try {
if (!$reg->save()) {
throw new CHttpException(500, 'Internal server error.');
}
foreach ($data as $key => $value) {
$param_value = new ParamValue();
$param_value->param_id = $value["id"];
$param_value->reg_id = $reg->id;
$param_value->value = $value["value"];
if (!$param_value->save()) {
// @todo Откат всех инсертов.
throw new CHttpException(500, 'Internal server error.');
}
}
echo CJSON::encode(array('code' => 200));
Yii::app()->end();
} catch (CDbException $error) {
throw new CHttpException(400, 'You are already registered for this event.');
}
}
$reg = Reg::model()->findByAttributes(array('user_id' => Yii::app()->user->getId(), 'event_id' => $id));
if ($reg !== null) {
$this->redirect(array('user/blank', 'userId' => Yii::app()->user->getId(), 'eventId' => $id));
Yii::app()->end();
}
$this->render('blank', array('event' => $event));
}