當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Documents::validate方法代碼示例

本文整理匯總了PHP中Documents::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Documents::validate方法的具體用法?PHP Documents::validate怎麽用?PHP Documents::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Documents的用法示例。


在下文中一共展示了Documents::validate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionDelZnoSubject

 public function actionDelZnoSubject($num)
 {
     $model = new Documents('ZNO');
     $subjects = array();
     $valid = true;
     if (isset($_GET["Documents"])) {
         $model->attributes = $_GET["Documents"];
         $model->validate();
     }
     if (isset($_GET["Documentsubject"])) {
         unset($_GET["Documentsubject"][$num]);
         foreach ($_GET["Documentsubject"] as $i => $obj) {
             $item = new Documentsubject();
             $item->attributes = $obj;
             if ($i == $num) {
                 $item->deleted = 1;
             }
             if ($item->deleted == 0) {
                 $valid = $item->validate() && $valid;
             }
             $subjects[] = $item;
         }
     }
     $this->renderPartial('_form', array('model' => $model, 'subjects' => $subjects));
 }
開發者ID:upmunspel,項目名稱:abiturient,代碼行數:25,代碼來源:DocumentsController.php

示例2: actionAppendBenefit

 public function actionAppendBenefit()
 {
     $model = new PersonBenefits();
     $documents = array();
     $valid = true;
     if (isset($_GET["PersonBenefits"])) {
         $model->attributes = $_GET["PersonBenefits"];
         if (isset($_GET["Documents"])) {
             foreach ($_GET["Documents"] as $i => $obj) {
                 $item = new Documents();
                 $item->attributes = $obj;
                 $valid = $valid && $item->validate();
                 $documents[] = $item;
             }
         }
     }
     if (!$valid) {
         echo CJSON::encode(array("result" => "suceess", "data" => $this->renderPartial('_form', array('model' => $model, 'documents' => $documents), true)));
     } else {
         /* save all new records */
         $flag = $transaction = Yii::app()->db->getCurrentTransaction();
         if ($transaction === null) {
             $transaction = Yii::app()->db->beginTransaction();
         }
         try {
             if ($model->save()) {
                 foreach ($documents as $doc) {
                     $doc->PersonID = $model->PersonID;
                     if ($doc->save()) {
                         if (empty($doc->idDocuments)) {
                             throw new Exception("idDocuments is empty!");
                         }
                         $rel = new PersonBenefitDocument();
                         $rel->DocumentID = $doc->getPrimaryKey();
                         $rel->PersonBenefitID = $model->idPersonBenefits;
                         $rel->save();
                     }
                 }
             }
             $transaction->commit();
             $person = Person::model()->findByPk($model->PersonID);
             echo CJSON::encode(array("result" => "success", "data" => $this->renderPartial("_benefits", array('models' => $person->benefits, 'personid' => $model->PersonID), true)));
         } catch (Exception $e) {
             if ($flag !== null) {
                 $transaction->rollback();
             }
             echo CJSON::encode(array("result" => "suceess", "data" => $e->getMessage()));
         }
     }
 }
開發者ID:upmunspel,項目名稱:abiturient,代碼行數:50,代碼來源:PersonbenefitsController_old.php


注:本文中的Documents::validate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。