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


PHP Quiz::getPrimaryKey方法代码示例

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


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

示例1: beforeSave

 protected function beforeSave()
 {
     if ($this->mediaType !== $this->_oldMediaType || $this->mediaType === $this->_oldMediaType && $this->mediaId == $this->_oldMediaId) {
         if ($this->_oldMediaType == "video") {
             $this->file->delete();
         } else {
             if ($this->_oldMediaType == "link") {
                 $this->mediaLink->delete();
             }
         }
     }
     if ($this->mediaType == "quiz" && $this->mediaId == 0) {
         $quiz = new Quiz();
         $quiz->save();
         $this->mediaId = $quiz->getPrimaryKey();
     }
     if (!$this->weight || !$this->number) {
         $criteria = new CDbCriteria();
         $criteria->condition = "courseId=" . intval($this->courseId);
         $criteria->select = "max(weight) as maxWeight,max(number) as maxNumber";
         $lesson = Lesson::model()->find($criteria);
         $chapter = Chapter::model()->find($criteria);
     }
     if (!$this->weight) {
         if (!$lesson && !chapter) {
             $this->weight = 1;
         } else {
             if (!$lesson) {
                 $this->weight = $chapter->maxWeight + 1;
             } else {
                 if (!$chapter) {
                     $this->weight = $lesson->maxWeight + 1;
                 } else {
                     $this->weight = max(array($chapter->maxWeight, $lesson->maxWeight)) + 1;
                 }
             }
         }
     }
     if (!$this->number) {
         if ($lesson) {
             $this->number = $lesson->maxNumber + 1;
         } else {
             $this->number = 1;
         }
     }
     return parent::beforeSave();
 }
开发者ID:stan5621,项目名称:jp_edu_online,代码行数:47,代码来源:Lesson.php

示例2: beforeSave

 protected function beforeSave()
 {
     //删除文件
     // if(!$this->isNewRecord){
     // 	if($this->mediaType!==$this->_oldMediaType
     // 		||($this->mediaType===$this->_oldMediaType && $this->mediaId!==$this->_oldMediaId)){
     // 		error_log(print_r($this,true));
     // 		if($this->_oldMediaType=="video"){
     // 			$this->file->delete();
     // 		}else if($this->_oldMediaType=="link"){
     // 			$this->mediaLink->delete();
     // 		}
     // 	}
     // }
     //创建quiz
     if ($this->mediaType == "quiz" && $this->mediaId == 0) {
         $quiz = new Quiz();
         $quiz->save();
         $this->mediaId = $quiz->getPrimaryKey();
     }
     if ($this->mediaType == "text" && $this->mediaId == 0) {
         $quiz = new Text();
         $quiz->save();
         $this->mediaId = $quiz->getPrimaryKey();
     }
     //设置课时数
     if (!$this->weight || !$this->number) {
         $criteria = new CDbCriteria();
         $criteria->condition = "courseId=" . intval($this->courseId);
         $criteria->select = "max(weight) as maxWeight,max(number) as maxNumber";
         $lesson = Lesson::model()->find($criteria);
         $chapter = Chapter::model()->find($criteria);
     }
     if (!$this->weight) {
         if (!$lesson && !chapter) {
             $this->weight = 1;
         } else {
             if (!$lesson) {
                 $this->weight = $chapter->maxWeight + 1;
             } else {
                 if (!$chapter) {
                     $this->weight = $lesson->maxWeight + 1;
                 } else {
                     $this->weight = max(array($chapter->maxWeight, $lesson->maxWeight)) + 1;
                 }
             }
         }
     }
     if (!$this->number) {
         if ($lesson) {
             $this->number = $lesson->maxNumber + 1;
         } else {
             $this->number = 1;
         }
     }
     return parent::beforeSave();
 }
开发者ID:stan5621,项目名称:eduwind,代码行数:57,代码来源:Lesson.php

示例3: actionUpdateQuiz

 public function actionUpdateQuiz($id)
 {
     $lesson = $this->loadModel($id);
     if (!$lesson->quiz) {
         $quiz = new Quiz();
         $quiz->save();
         $lesson->deleteMedia();
         $lesson->mediaId = $quiz->getPrimaryKey();
         $lesson->save();
     }
     $this->redirect(array('quiz/view', 'id' => $quiz->id));
 }
开发者ID:stan5621,项目名称:eduwind,代码行数:12,代码来源:LessonController.php


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