本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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']);