本文整理汇总了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;
}