當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Department::read方法代碼示例

本文整理匯總了PHP中Department::read方法的典型用法代碼示例。如果您正苦於以下問題:PHP Department::read方法的具體用法?PHP Department::read怎麽用?PHP Department::read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Department的用法示例。


在下文中一共展示了Department::read方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: import

 public function import($department_id = null, $semester_id = null)
 {
     // 		debug($_FILES);
     $this->layout = 'ajax';
     //* 	extjs的上傳 */
     if ($this->request->is('post')) {
         if ($_FILES['import']['error'] > 0) {
             $error = $_FILES['import']['error'];
             $response = array('success' => false, 'msg' => $error);
             echo json_encode($response);
         } else {
             $file_name = $_FILES['import']['name'];
             $file_type = $_FILES['import']['type'];
             $file_size = round($_FILES['import']['size'] / 1024, 2) . '  Kilo Bytes';
             $uploaddir = WWW_ROOT . "uploads/";
             //debug(WWW_ROOT);
             /*取時間戳為文件名*/
             $name = basename($_FILES['import']['name']);
             $name = $this->rm($name);
             //debug($name);
             $uploadfile = $uploaddir . $name;
             // 			/*取原名為文件名*/
             //$uploadfile = $uploaddir . basename($_FILES['import']['name']);
             /* 如果上傳文件名有亂碼 */
             /* $uploadfile=iconv("utf-8","GBK", $uploadfile); */
             if (move_uploaded_file($_FILES['import']['tmp_name'], $uploadfile)) {
                 // 					echo "File is valid, and was successfully uploaded.\n";}
                 //debug($uploadfile);
                 $data = $this->showXls($uploadfile, $department_id, $semester_id);
                 $dataLength = count($data);
                 // 										debug($data);
                 $elective_data = array();
                 foreach ($data as $value) {
                     $stu_number = $value['stu_number'];
                     $course_id = $value['course'];
                     $elective_data[$stu_number] = $course_id;
                     // 								debug($value);
                 }
                 // 							debug($elective_data);
                 $this->Elective->unbindModel(array('belongsTo' => array('CoursePlan', 'Course', 'Student')));
                 App::import('Controller', 'CoursePlans');
                 $CoursePlan = new CoursePlansController();
                 $coursepalns = $CoursePlan->listCoursePlans($department_id, $semester_id, null, 2, true);
                 foreach ($coursepalns as $courseplan) {
                     $courseplan_id[] = $courseplan['CoursePlan']['id'];
                 }
                 $Department = new Department();
                 $depts = $Department->read('dept_number', $department_id);
                 $options = array('conditions' => array('stu_number like' => $depts['Department']['dept_number'] . '%', 'course_plan_id' => $courseplan_id));
                 // 							debug($options);
                 $stu_electiv_namelist = $this->Elective->find('all', $options);
                 // 							debug($stu_electiv_namelist);
                 $num_of_success = 0;
                 $data = array();
                 foreach ($stu_electiv_namelist as $idx => $record) {
                     // 								debug($student_record);
                     $id = $record['Elective']['id'];
                     $stu_number = $record['Elective']['stu_number'];
                     $data[$idx]['id'] = $id;
                     $data[$idx]['stu_number'] = $stu_number;
                     if (isset($elective_data[$stu_number])) {
                         $data[$idx]['course_id'] = $elective_data[$stu_number];
                         $elective_data[$stu_number] == 0 ?: $num_of_success++;
                     }
                 }
                 // 							debug($data);
                 if ($this->Elective->saveAll($data)) {
                     // 						echo 'ok';
                     $success = true;
                 } else {
                     // 					echo 'no';
                     $success = false;
                 }
                 $response = array('success' => true, 'data' => array('name' => $file_name, 'size' => $file_size), 'msg' => '上傳了' . $dataLength . '條記錄,成功導入了' . $num_of_success . '條記錄。');
                 echo json_encode($response);
             }
         }
     }
     die;
 }
開發者ID:phoenixwubo,項目名稱:SIS,代碼行數:80,代碼來源:ElectivesController.php

示例2: elective

 public function elective($course_plan_id, $course_id = 0, $course_type, $department_id, $semester_id)
 {
     $Department = new Department();
     $success = false;
     $depts = $Department->read('dept_number', $department_id);
     // 	$depts=$Departments->getChildren($department_id);
     // 	$conditions['Student.stu_number LIKE']=$depts['Department']['dept_number'].'%';
     $options = array('conditions' => array('dept_number like' => $depts['Department']['dept_number'] . '%'));
     //debug($options);
     $Student = new Student();
     $students = $Student->find('all', $options);
     // 		debug($students);
     $data = array();
     foreach ($students as $student) {
         $data[] = array('stu_number' => $student['Student']['stu_number'], 'dept_number' => $student['Student']['dept_number'], 'course_plan_id' => $course_plan_id, 'course_type' => $course_type, 'course_id' => $course_id);
     }
     // 					debug($data);
     if ($data != array()) {
         $Elective = new Elective();
         $success = $Elective->saveAll($data);
     }
     // 	$dept_number=
     // 	$students=
     // 			die();
     return $success;
 }
開發者ID:phoenixwubo,項目名稱:SIS,代碼行數:26,代碼來源:CoursePlansController.php


注:本文中的Department::read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。