本文整理匯總了PHP中School::findFirst方法的典型用法代碼示例。如果您正苦於以下問題:PHP School::findFirst方法的具體用法?PHP School::findFirst怎麽用?PHP School::findFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類School
的用法示例。
在下文中一共展示了School::findFirst方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: indexAction
public function indexAction($school_id = 0, $error = null)
{
if (!isset($error)) {
$this->session->set("school_id", $school_id);
$this->view->setVar("error", false);
} else {
$this->view->setVar("error", $error);
}
$school = School::findFirst(array("school_id=:school_id:", "bind" => array("school_id" => $this->session->get("school_id"))));
if ($school != null) {
$this->view->setVar("school_name", $school->name);
} else {
$this->view->setVar("school_name", "");
$this->flash->error("對不起,您訪問的學校不存在");
}
$this->view->setVar("type", "student");
$this->view->setVar("target", "/stulogin/check");
}
示例2: exportAction
public function exportAction()
{
$this->view->disable();
if ($this->request->isGet()) {
$this->response->setHeader("Content-Type", "application/force-download");
$this->response->setHeader("Content-Transfer-Encoding", "binary");
$this->response->setHeader("Pragma", "no-cache");
$this->response->setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
$base_row = 5;
$excel = new PHPExcel();
$sheet = $excel->getSheet(0);
$sheet->setTitle("sheet0");
$filename = $this->create_uuid() . ".xls";
$manager = $this->session->get("manager");
$test_id = $this->request->get("test_id");
$school_id = $manager["school_id"];
$test = Test::findFirst($test_id);
$school = School::findFirst($school_id);
$sheet->setCellValue("A1", "學校");
$sheet->setCellValue("B1", $school->name);
$sheet->setCellValue("A2", "地區");
$sheet->setCellValue("B2", $school->district);
$sheet->setCellValue("A3", "測試名稱");
$sheet->setCellValue("B3", $test->description);
$sheet->setCellValue("A4", "姓名");
$sheet->setCellValue("B4", "學號");
$sheet->setCellValue("C4", "性別");
$sheet->setCellValue("D4", "出生日期");
$sheet->setCellValue("E4", "民族");
$sheet->setCellValue("F4", "是否獨生子女");
$sheet->setCellValue("G4", "生源地");
$sheet->setCellValue("H4", "院係");
$sheet->setCellValue("I4", "專業");
$sheet->setCellValue("J4", "年級");
$sheet->setCellValue("K4", "班級");
$base_col = "L";
foreach ($test->Part as $part) {
$sheet->setCellValue($base_col . "4", $part->name);
$base_col++;
}
foreach ($test->Student as $student) {
$sheet->setCellValue("A" . $base_row, $student->name);
$sheet->setCellValue("B" . $base_row, $student->stu_no);
$sex = $student->sex == 0 ? "女" : "男";
$sheet->setCellValue("C" . $base_row, $sex);
$sheet->setCellValue("D" . $base_row, $student->birthday);
$sheet->setCellValue("E" . $base_row, $student->nation);
$singleton = $student->singleton == 0 ? "否" : "是";
$sheet->setCellValue("F" . $base_row, $singleton);
$nativeplace = $student->nativeplace == 0 ? "農村" : "城鎮";
$sheet->setCellValue("G" . $base_row, $nativeplace);
$sheet->setCellValue("H" . $base_row, $student->college);
$sheet->setCellValue("I" . $base_row, $student->major);
$sheet->setCellValue("J" . $base_row, $student->grade);
$sheet->setCellValue("K" . $base_row, $student->class);
$base_col = "L";
foreach ($student->Total as $total) {
$sheet->setCellValue("{$base_col}" . "{$base_row}", $total->answers);
$base_col++;
}
$base_row++;
}
$writer = PHPExcel_IOFactory::createWriter($excel, "Excel5");
$writer->save("../cache/temp/{$filename}");
$excel->disconnectWorksheets();
$this->response->setFileToSend("../cache/temp/{$filename}", $test->description . "學生資料.xls");
$this->response->send();
//return $response;
}
}
示例3: addStudent
public function addStudent($filename)
{
$this->db->begin();
$school = School::findFirst(array('name = :filename:', 'bind' => array('filename' => substr($filename, 0, strlen($filename) - 4))));
try {
$test = $this->addTest($school);
$this->addstudents($filename, $test->t_id, $school->school_id);
} catch (PDOException $ex) {
$this->db->rollback();
return $ex->getMessage();
}
$this->db->commit();
}