本文整理匯總了PHP中Answer::put方法的典型用法代碼示例。如果您正苦於以下問題:PHP Answer::put方法的具體用法?PHP Answer::put怎麽用?PHP Answer::put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Answer
的用法示例。
在下文中一共展示了Answer::put方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: foreach
}
foreach ($answer_data as $k => $v) {
$answer->{$k} = $v;
}
$answer->points = intval($answer->points);
$answers[] = $answer;
}
$question->put();
foreach ($answers as $answer) {
$answer->question_id = $question->id;
$answer->test_id = $question->test_id;
$answer->normalize();
$answer->put_or_delete();
if (!$answer->is_empty()) {
$answer->normalize();
$answer->put();
}
}
jsdie("questionSaved", $question->id, $is_new);
}
if ($is_new) {
$title = "Новый вопрос";
$question = new Question();
$question->id = 'new';
$question->test_id = $_REQUEST['test_id'];
$question->wakeup();
$answers = array();
} else {
if (!($question = Question::get("WHERE id = %s", $id))) {
redirect("/", "Извините, этот вопрос уже удален.");
}
示例2: Question
function add_question($test, $text, $answers)
{
if (!isset($test->question_count)) {
$test->question_count = 0;
}
$question = new Question();
$question->test_id = $test->id;
$question->order = ++$test->question_count;
$question->text = $text;
$question->put();
$question->all_answers = array();
$answer_count = 0;
foreach ($answers as $answer_text) {
$answer = new Answer();
$answer->question_id = $question->id;
$answer->order = ++$answer_count;
$answer->text = $answer_text;
$answer->put();
$question->all_answers[] = $answer;
}
$test->all_questions[] = $question;
}