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


PHP CActiveRecord::getErrors方法代码示例

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


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

示例1: assertSaves

 /**
  * Assert thet the model can be saved without error and, if errors are present, print
  * out the corresponding error messages.
  * @param CActiveRecord $model
  */
 public function assertSaves(CActiveRecord $model)
 {
     $saved = $model->save();
     if ($model->hasErrors()) {
         VERBOSE_MODE && print_r($model->getErrors());
     }
     $this->assertTrue($saved);
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:13,代码来源:X2TestCase.php

示例2: saveActiveRecord

 public function saveActiveRecord(CActiveRecord $record)
 {
     try {
         if (!$record->save()) {
             new \Error(5, null, json_encode($record->getErrors()));
         }
     } catch (Exception $e) {
         new \Error(5, null, $e->getMesaage());
     }
 }
开发者ID:Yougmark,项目名称:TiCheck_Server,代码行数:10,代码来源:ModifyController.php

示例3: checkErrors

 /**
  *### .checkErros()
  *
  * errors as CHttpException
  * @internal param $msg
  */
 public function checkErrors()
 {
     if ($this->model->hasErrors()) {
         $msg = array();
         foreach ($this->model->getErrors() as $attribute => $errors) {
             $msg = array_merge($msg, $errors);
         }
         //todo: show several messages. should be checked in x-editable js
         //$this->error(join("\n", $msg));
         $this->error($msg[0]);
     }
 }
开发者ID:robebeye,项目名称:isims,代码行数:18,代码来源:TbEditableSaver.php

示例4: checkErrors

 /**
  *### .checkErros()
  *
  * errors as CHttpException
  * @internal param $msg
  * @throws CHttpException
  */
 public function checkErrors()
 {
     if (!$this->model->hasErrors()) {
         return;
     }
     $msg = array();
     foreach ($this->model->getErrors() as $attribute => $errors) {
         // TODO: make use of $attribute elements
         $msg = array_merge($msg, $errors);
     }
     $this->error($msg[0]);
 }
开发者ID:zhaoyan158567,项目名称:YiiBooster,代码行数:19,代码来源:TbEditableSaver.php

示例5: afterValidate

 /**
  * Extended after validate function from CFormModel that validates associated
  * active record as well
  * @param array $attributes
  * @param boolean $clearErrors
  * @return boolean
  */
 public function afterValidate($attributes = null, $clearErrors = true)
 {
     if ($this->model != null) {
         if ($this->model->validate()) {
             return true;
         } else {
             $errors = $this->model->getErrors();
             $this->addErrors($errors);
             return false;
         }
     }
     return true;
 }
开发者ID:nncrypted,项目名称:Sommelier,代码行数:20,代码来源:FrApiResource.php

示例6: update

 /**
  * main function called to update column in database
  *
  */
 public function update()
 {
     //set params from request
     $this->primaryKey = yii::app()->request->getParam('pk');
     $this->attribute = yii::app()->request->getParam('name');
     $value = Yii::app()->request->getParam('value');
     //checking params
     if (empty($this->attribute)) {
         throw new CException(Yii::t('zii', 'Property "attribute" should be defined.'));
     }
     if (empty($this->primaryKey)) {
         throw new CException(Yii::t('zii', 'Property "primaryKey" should be defined.'));
     }
     //loading model
     $this->model = CActiveRecord::model($this->modelClass)->findByPk($this->primaryKey);
     if (!$this->model) {
         throw new CException(Yii::t('editable', 'Model {class} not found by primary key "{pk}"', array('{class}' => get_class($this->model), '{pk}' => $this->primaryKey)));
     }
     $this->model->setScenario($this->scenario);
     //is attribute exists
     if (!$this->model->hasAttribute($this->attribute)) {
         throw new CException(Yii::t('editable', 'Model {class} does not have attribute "{attr}"', array('{class}' => get_class($this->model), '{attr}' => $this->attribute)));
     }
     //is attribute safe
     if (!$this->model->isAttributeSafe($this->attribute)) {
         throw new CException(Yii::t('zii', 'Model {class} rules do not allow to update attribute "{attr}"', array('{class}' => get_class($this->model), '{attr}' => $this->attribute)));
     }
     //setting new value
     $this->setAttribute($this->attribute, $value);
     //validate
     $this->model->validate(array($this->attribute));
     if ($this->model->hasErrors()) {
         $this->error($this->model->getError($this->attribute));
     }
     //save
     if ($this->beforeUpdate()) {
         //saving (only chnaged attributes)
         if ($this->model->save(false, $this->changedAttributes)) {
             $this->afterUpdate();
         } else {
             $this->error(Yii::t('zii', 'Error while saving record!'));
         }
     } else {
         $firstError = reset($this->model->getErrors());
         $this->error($firstError[0]);
     }
 }
开发者ID:janym,项目名称:angular-yii,代码行数:51,代码来源:TbEditableSaver.php

示例7: assertSaves

 /**
  * Assert thet the model can be saved without error and, if errors are present, print
  * out the corresponding error messages.
  * @param CActiveRecord $model
  */
 public function assertSaves(CActiveRecord $model)
 {
     $saved = $model->save();
     if ($model->hasErrors()) {
         X2_TEST_DEBUG_LEVEL > 1 && print_r($model->getErrors());
     }
     $this->assertTrue($saved);
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:13,代码来源:X2TestCase.php

示例8: modelIsNotSaved

 /**
  * Log exception model is not saved due to validation failed
  *
  * @param CActiveRecord $model
  * @param null          $result if not set then the $model is used as result
  * @param               $returnCode
  *
  * @return XException
  */
 public function modelIsNotSaved(CActiveRecord $model, $result = null, $returnCode = -1)
 {
     $errorData = $model->getErrors();
     $errorData['message'] = get_class($model) . ' information is not saved. ' . CHtml::errorSummary($model);
     return $this->eh->logException(isset($result) ? $result : $model, $returnCode, self::ERR_AR_IS_NOT_SAVED, $errorData);
 }
开发者ID:hung5s,项目名称:yap,代码行数:15,代码来源:XCommonExceptionLogger.php


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