本文整理汇总了PHP中Question::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::update方法的具体用法?PHP Question::update怎么用?PHP Question::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAnswer
function addAnswer()
{
$question = new Question($_POST);
if ($question1 = Question::getAnswerByUserId($_SESSION['userId'], $question->question)) {
$question->id = $question1->id;
$question->update();
} else {
$question->insert();
}
header('main.php?action = login');
}
示例2: Question
function test_update()
{
//Arrange
$test_field = "What is their name?";
$test_description = "What you want to call your character.";
$test_question = new Question($test_field, $test_description);
$test_question->save();
$new_quest = "How tall are they?";
$new_desc = "The height you want your character to be.";
//Act
$test_question->update($new_quest, $new_desc);
//Assert
$this->assertEquals(["How tall are they?", "The height you want your character to be."], [$test_question->getQuestion(), $test_question->getDescription()]);
}
示例3: connectToEncryptedMySQL
<?php
require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
require_once "question.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/jfindley2.ini");
$question = new Question(null, 1, 2, "Huh?", null);
$question->insert($pdo);
$question->setQuestionText("What?");
$question->update($pdo);
$question->delete($pdo);
示例4: init
function init()
{
$question = new Question();
$func = array_shift($this->param);
if (is_numeric($func)) {
$this->id = $func;
} else {
if ($func != '') {
$_SERVER['REQUEST_METHOD'] = 'POST';
$course_id = array_shift($this->param);
Security::checkEditor($course_id);
switch ($func) {
case 'save':
$data['course_id'] = $course_id;
$data['type_id'] = $_POST['type_id'];
$data['data'] = $_POST['data'];
$data['count'] = $_POST['count'];
$data['answer'] = $_POST['answer'];
$id = $_POST['id'];
try {
$question->update($id, $data);
} catch (Exception $e) {
}
header('Location: /admin_questions/' . $data['course_id']);
exit;
break;
case 'delete':
try {
$question_id = array_shift($this->param);
$question->delete($question_id);
echo "ok";
} catch (Exception $e) {
echo $e;
}
header('Location: /admin_questions/' . $course_id);
exit;
break;
case 'find':
try {
$data = array('course_id' => $course_id, 'type_id' => 0, 'data' => '', 'answer' => '');
$q_id = $question->add($data);
$data['id'] = $q_id;
echo json_encode($data);
} catch (Exception $e) {
echo $e;
}
exit;
break;
case 'load':
try {
$question_id = array_shift($this->param);
$data = $question->get(array('course_id' => $course_id, 'id' => $question_id));
echo json_encode($data);
} catch (Exception $e) {
echo $e;
}
exit;
break;
default:
}
} else {
header('Location: /404');
exit;
}
}
}