本文整理汇总了PHP中Reg::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Reg::model方法的具体用法?PHP Reg::model怎么用?PHP Reg::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reg
的用法示例。
在下文中一共展示了Reg::model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Reg the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Reg::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $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));
}