当前位置: 首页>>代码示例>>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;未经允许,请勿转载。