当前位置: 首页>>代码示例>>PHP>>正文


PHP Person::getErrors方法代码示例

本文整理汇总了PHP中app\models\Person::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::getErrors方法的具体用法?PHP Person::getErrors怎么用?PHP Person::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Person的用法示例。


在下文中一共展示了Person::getErrors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 public function actionCreate()
 {
     if (count($_POST) > 0) {
         $personInfo = ['firstname' => strtolower(\Yii::$app->request->post('firstname')), 'lastname' => strtolower(\Yii::$app->request->post('lastname')), 'dob' => date('Y-m-d', strtotime(\Yii::$app->request->post('dob'))), 'zip' => \Yii::$app->request->post('zip')];
         $person = new Person($personInfo);
         $saved = $person->save();
         if (!$saved) {
             $errors = $person->getErrors();
             foreach ($errors as $messages) {
                 foreach ($messages as $message) {
                     \Yii::$app->session->addFlash('danger', $message);
                 }
             }
             header("Location: /persons/web/add");
             exit;
         }
         \Yii::$app->session->addFlash('success', 'Record added successfully.');
         header("Location: /persons/web/person/{$person->id}");
         exit;
     }
     return $this->render('create');
 }
开发者ID:jrss95,项目名称:persons,代码行数:22,代码来源:SiteController.php

示例2: savePersons

 /**
  * Сохраняем участников или консультантов
  *
  * @param $data array
  * @param $nType integer
  */
 public function savePersons($data, $nType)
 {
     $bOk = true;
     Person::updateAll(['prs_active' => 0, 'prs_type' => 0, 'prs_sec_id' => 0, 'prs_doc_id' => 0], ['prs_doc_id' => $this->doc_id, 'prs_type' => $nType]);
     foreach ($data as $ob) {
         $ob['prs_type'] = $nType;
         $ob['prs_doc_id'] = $this->doc_id;
         $ob['prs_active'] = Person::PERSON_STATE_ACTIVE;
         $ob['prs_sec_id'] = $this->doc_sec_id;
         //            Yii::info('consultant = ' . print_r($ob, true));
         $s = 'Update ' . Person::tableName() . ' Set ';
         $param = [];
         $sDelim = '';
         if (empty($ob['prs_org']) && !empty($ob['prs_hischool'])) {
             $ob['prs_org'] = $ob['prs_hischool'];
         }
         foreach ($ob as $k => $v) {
             $s .= $sDelim . $k . ' = ' . ':' . $k;
             $param[':' . $k] = $v;
             $sDelim = ', ';
         }
         $s .= ' Where prs_active = 0 And prs_type = 0 And prs_sec_id = 0 And prs_doc_id = 0 Limit 1';
         //            Yii::info($s);
         $n = Yii::$app->db->createCommand($s, $param)->execute();
         if ($n == 0) {
             $oNew = new Person();
             $oNew->prs_type = $nType;
             $aTmp = $oNew->scenarios();
             $oNew->attributes = $ob;
             $oNew->prs_doc_id = $this->doc_id;
             $oNew->prs_active = Person::PERSON_STATE_ACTIVE;
             $oNew->prs_sec_id = $this->doc_sec_id;
             if (!$oNew->save()) {
                 $bOk = false;
                 Yii::info('savePersons() nType = ' . $nType . ' attributes: ' . print_r($oNew->attributes, true));
                 Yii::info('savePersons() nType = ' . $nType . ' Error save oNew: ' . print_r($oNew->getErrors(), true));
             }
         }
     }
     return $bOk;
 }
开发者ID:mosedu,项目名称:confprof,代码行数:47,代码来源:Doclad.php

示例3: actionCreate

 /**
  * Creates a new Person model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Person();
     $jobModel = new Job();
     if ($jobModel->load(Yii::$app->request->post()) && $jobModel->validate() && $model->load(Yii::$app->request->post()) && $model->validate()) {
         $transaction = $model->getDb()->beginTransaction();
         try {
             if (is_numeric($jobModel->name)) {
                 $jobModel = $jobModel->findOne($jobModel->name);
             } else {
                 $jobModel = new Job();
                 $jobModel->load(Yii::$app->request->post());
                 if (!$jobModel->save(false)) {
                     throw new Exception(Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($jobModel->tableName())), 'msj' => print_r($jobModel->getErrors(), true)]), 500);
                 }
             }
             $model->job_id = $jobModel->id;
             if (!$model->save(false)) {
                 throw new Exception(Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($model->tableName())), 'msj' => print_r($model->getErrors(), true)]), 500);
             }
             $transaction->commit();
         } catch (\Exception $e) {
             $transaction->rollBack();
             throw $e;
         }
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'jobModel' => $jobModel]);
     }
 }
开发者ID:edarkzero,项目名称:mi_taller,代码行数:35,代码来源:PersonController.php


注:本文中的app\models\Person::getErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。