本文整理匯總了PHP中Test::findFirst方法的典型用法代碼示例。如果您正苦於以下問題:PHP Test::findFirst方法的具體用法?PHP Test::findFirst怎麽用?PHP Test::findFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Test
的用法示例。
在下文中一共展示了Test::findFirst方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: viewAction
public function viewAction($index)
{
$this->response->setHeader("Content-Type", "text/html; charset=utf-8");
$test = Test::findFirst(array("t_id=:t_id:", "bind" => array("t_id" => $index)));
$students = $test->getStudent();
$done = 0;
foreach ($students as $student) {
$done += $student->status;
}
$sum = count($students);
$this->view->setVar("notdone", $sum - $done);
$this->view->setVar("sum", $sum);
$this->view->setVar("test_id", $index);
$this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW);
}
示例2: surveyAction
public function surveyAction()
{
$this->assets->collection("header")->addJs("lib/stickUp.min.js");
// $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_AFTER_TEMPLATE);
if ($this->request->isGet()) {
$isfirst = $this->request->get("isfirst");
if ($isfirst == 1) {
$this->session->set("p_start", strtotime(date("Y-m-d H:i:s")));
$test_id = $this->session->get("test_id");
$test = Test::findFirst(array("t_id=:t_id:", "bind" => array("t_id" => $test_id)));
$parts = array();
foreach ($test->Part as $index => $part) {
$parts[$index] = $part->p_id;
}
$part_num = $this->session->get("exam_num");
$this->session->set("parts", $parts);
$answer_num = $this->session->get("answer_num");
if ($answer_num != 0 && $answer_num < $part_num) {
$result = $this->nextpart(-1, $this->session->get("answer_num"));
} else {
if ($answer_num == 0) {
$result = new SurveyResult();
$tnext = $part_num == 1 ? -1 : 1;
$cacheKey = $test->Part[0]->p_id . ".txt";
$result->description = $test->Part[0]->description;
$result->nextpart = $this->getquestion($test->Part[0], $cacheKey);
$result->resultinfo = 1;
$result->cur = 0;
$this->session->set("cur", 0);
$this->session->set("next", $tnext);
$result->next = $tnext;
} else {
$this->response->redirect("student/index");
}
}
} else {
if ($isfirst == 2) {
$result = $this->nextpart($this->session->get("cur"), $this->session->get("next"));
} else {
$this->response->redirect("student/index");
}
}
$this->view->setVar("testinfo", $result);
} else {
$this->response->redirect("student/index");
}
}