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


PHP Question::setId方法代码示例

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


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

示例1: add

 public function add(Question $question)
 {
     $a = array(StudyPressDB::COL_CONTENT_QUESTION => $question->getContent(), StudyPressDB::COL_ID_QUIZ_QUESTION => $question->getQuizId(), StudyPressDB::COL_TYPE_QUESTION => $question->getType(), StudyPressDB::COL_ORDER_QUESTION => $this->getLastOrder($question->getQuizId()) + 1);
     $this->_access->insert(StudyPressDB::getTableNameQuestions(), $a);
     $idQuestion = $this->_access->getLastInsertId();
     $question->setId($idQuestion);
     return $idQuestion;
 }
开发者ID:Cossumo,项目名称:studypress,代码行数:8,代码来源:QuestionManager.class.php

示例2: create

 /**
  * If $recruiter is set, vanilla will be false. If $recruiter is null,
  * vanilla will be true.
  */
 private static function create($text, MongoId $recruiter = null)
 {
     // Check if question already exists (model function). If so, return
     // the question.
     $existingQuestion = QuestionModel::getByExactText($text);
     if (!is_null($existingQuestion)) {
         return self::parseRawData($existingQuestion);
     }
     // Construct question with parameters.
     $vanilla = is_null($recruiter);
     $question = new Question(['text' => $text, 'recruiter' => $recruiter, 'vanilla' => $vanilla]);
     // Pass (question object or raw data?) to model to store in database with
     // custom flag.
     $id = QuestionModel::insert($question->getData());
     $question->setId($id);
     // Return created question.
     return $question;
 }
开发者ID:davidliuliuliu,项目名称:sublite,代码行数:22,代码来源:Question.php

示例3: get

 /**
  * @return Question
  * @param int $id
  */
 public static function get($id)
 {
     $db = DB::getConn();
     $stm = $db->prepare('select * from Question where id = :id');
     $stm->bindParam(':id', $id);
     $stm->execute();
     $rs = $stm->fetchAll()[0];
     $q = new Question($rs['category'], $rs['point'], $rs['title'], $rs['explain']);
     $q->setId($id);
     $stm = $db->prepare('select * from Option where question = :id');
     $stm->bindParam(':id', $id);
     $stm->execute();
     $arr = $stm->fetchAll();
     foreach ($arr as $o) {
         $opt = new Option($o['question'], $o['title'], $o['isCorrect'] ? true : false);
         $opt->setId($o['id']);
         $q->addOpt($opt);
     }
     return $q;
 }
开发者ID:rmit-s3443163-quan-do,项目名称:its,代码行数:24,代码来源:QuestionCtrl.php

示例4: htmlspecialchars

        $c1 = 'selected';
    } else {
        $c2 = 'selected';
    }
}
if (isset($_POST['title']) && $_POST['title'] != '') {
    $cate = htmlspecialchars($_POST['cate']);
    $point = htmlspecialchars($_POST['point']);
    $title = htmlspecialchars($_POST['title']);
    $explain = htmlspecialchars($_POST['explain']);
    $q_tmp = new Question($cate, $point, $title, $explain);
    $update = false;
    if (isset($_POST['ques_id']) && $_POST['ques_id'] != '') {
        $update = true;
        $qid = $_POST['ques_id'];
        $q_tmp->setId($qid);
        QuestionCtrl::updateQuestion($q_tmp);
    } else {
        $qid = QuestionCtrl::addQuestion($q_tmp);
    }
    if ($qid > 0) {
        $opt1 = htmlspecialchars($_POST['opt1']);
        $optCR1 = isset($_POST['opt1-cr']);
        $o = new Option($qid, $opt1, $optCR1);
        if ($update) {
            $o->setId($_POST['o1-id']);
            QuestionCtrl::updateOption($o);
        } else {
            QuestionCtrl::addOption($o);
        }
        $opt2 = htmlspecialchars($_POST['opt2']);
开发者ID:rmit-s3443163-quan-do,项目名称:its,代码行数:31,代码来源:a_question_bk.php


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