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


PHP Answer::get方法代码示例

本文整理汇总了PHP中Answer::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Answer::get方法的具体用法?PHP Answer::get怎么用?PHP Answer::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Answer的用法示例。


在下文中一共展示了Answer::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: next

 public function next()
 {
     $q_id = Param::get('id');
     $selection_id = Param::get('selection');
     $question = Question::get();
     $answer = Answer::get($q_id);
     $this->set(['question' => $question, 'answer' => $answer, 'selection_id' => $selection_id]);
     $this->render('index');
 }
开发者ID:b-kaxa,项目名称:perld,代码行数:9,代码来源:default_controller.php

示例2: submitPoll

 public function submitPoll($data, $form)
 {
     $choices = Answer::get()->filter(array('ID' => $data['PollChoices']));
     if ($choices) {
         foreach ($choices as $choice) {
             $choice->Votecount = $choice->Votecount + 1;
             $choice->write();
             $choice->Poll()->markAsVoted();
         }
     }
     $this->controller->redirectBack();
 }
开发者ID:helpfulrobot,项目名称:firesphere-poll,代码行数:12,代码来源:PollForm.php

示例3: action_edit

 public static function action_edit($id = null)
 {
     if (!IS_ADMIN) {
         Redirect::to(Url::get('admin@login', null, 'redirect-to=' . urlencode(Url::current())));
     }
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         if ($id === 'delete-answer') {
             if (($answer_id = Param::post('answer_id')) && is_numeric($answer_id)) {
                 $answer = Answer::get((int) $answer_id);
                 Answer::find((int) $answer_id)->delete();
                 $votes = Vote::where('answer_id', '=', $answer_id)->count();
                 if ($votes) {
                     Poll::find($answer->poll_id)->set(array('nofilter:total_votes' => "`total_votes` - {$votes}"));
                 }
                 return Response::json(array('status' => 200, 'deleted' => true));
             } else {
                 return Response::json(array('status' => 0, 'deleted' => false));
             }
         } elseif ($id) {
             return Response::error(404);
         } else {
             $id = Param::post('id');
             if ($answer_id = Param::post('remove_answer')) {
                 Answer::find((int) $answer_id)->and_where('poll_id', '=', $id)->delete();
                 $votes = Vote::where('answer_id', '=', $answer_id)->count();
                 if ($votes) {
                     Poll::find($id)->set(array('nofilter:total_votes' => "`total_votes` - {$votes}"));
                 }
                 Redirect::to(Url::get('admin@edit', $id, 'answer_deleted=true'));
             }
             if (Param::post('remove_poll')) {
                 Poll::find($id)->delete();
                 Redirect::to(Url::get('admin', null, 'poll_deleted=true'));
             }
             if (is_numeric($id) && ($poll = Poll::get((int) $id))) {
                 foreach ($_POST as $key => $value) {
                     if (isset($poll->{$key}) && (!empty($_POST[$key]) || $_POST[$key] === "0")) {
                         $poll->{$key} = is_numeric($_POST[$key]) ? intval($_POST[$key], 10) : $_POST[$key];
                     } elseif (false !== strpos($key, 'answer-')) {
                         $answer_id = explode('-', $key);
                         $answer_id = $answer_id[1];
                         if (is_numeric($answer_id)) {
                             Answer::find((int) $answer_id)->set(array('text' => $value));
                         }
                     } elseif ($key === 'new_answers') {
                         foreach ($value as $new_answer) {
                             if (!empty($new_answer)) {
                                 Answer::create(array('poll_id' => (int) $poll->id, 'text' => $new_answer));
                             }
                         }
                     }
                 }
                 Poll::save($poll);
                 Redirect::to(Url::get('admin', null, 'success=' . $_POST['id'] . '&updated=true'));
             } else {
                 return Response::error(500);
             }
         }
     }
     if (!$id || !is_numeric($id) || !($poll = Poll::get((int) $id))) {
         return Response::error(404);
     } else {
         $answers = Answer::where('poll_id', '=', $poll->id)->get();
         return View::make('admin.edit')->add_var('answers', $answers)->add_var('poll', $poll);
     }
 }
开发者ID:jruizdes,项目名称:encuestamanki,代码行数:66,代码来源:admin.php

示例4: redirect

 if (!isset($_SESSION['tests']) || !isset($_SESSION['tests'][$test_id])) {
     include 'templates/test_expired.inc.php';
     exit;
 }
 $RES =& $_SESSION['tests'][$test_id];
 if ($RES->finished) {
     redirect("/tests/{$test->id}/");
     die;
 }
 $answer_id = intval($_POST['answer']);
 if ($answer_id == 0) {
     die("Bad request: answer not specified");
 }
 $question = Question::get("WHERE `id` = %d AND `test_id` = %d", $RES->question_id, $test->id);
 if ($question) {
     $answer = Answer::get("WHERE `id`=%d AND `question_id`=%d", $answer_id, $question->id);
     if ($answer) {
         $a = new QuestionResult();
         $a->question_id = $question->id;
         $a->question_ord = $question->order;
         $a->ord = $answer->order;
         $a->points = $answer->points;
         $RES->answers[] = $a;
     }
 }
 include $test->handler_file();
 if (!function_exists('next_action')) {
     die("Invalid handler {$handler_file}: a handler must define function next_action(\$RES, \$question_count)");
 }
 $question = run_handler($RES, $test, $question ? $question->id : 0, $answer ? $answer->id : 0);
 redirect("/tests/{$test->id}/");
开发者ID:andreyvit,项目名称:retester,代码行数:31,代码来源:test.php


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