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


PHP Answer::put方法代码示例

本文整理汇总了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("/", "Извините, этот вопрос уже удален.");
    }
开发者ID:andreyvit,项目名称:retester,代码行数:31,代码来源:question_editor.php

示例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;
 }
开发者ID:andreyvit,项目名称:retester,代码行数:22,代码来源:setup.php


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