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


PHP School::findFirst方法代码示例

本文整理汇总了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");
 }
开发者ID:sify21,项目名称:Question,代码行数:18,代码来源:StuloginController.php

示例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;
     }
 }
开发者ID:sify21,项目名称:Question,代码行数:70,代码来源:IndexController.php

示例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();
 }
开发者ID:sify21,项目名称:Question,代码行数:13,代码来源:ImportController.php


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