public function score($course_plan_id, $department_id) { //$course_plan_id=1; //$department_id=38; $Department = new Department(); $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' => 1); } // debug($data); $Score = new Score(); $success = $Score->saveAll($data); return $success; // $dept_number= // $students= }