From 1b5863174162f67b4cbb9d71b03cc6bd60626b8c Mon Sep 17 00:00:00 2001 From: xamgore <xamgore@ya.ru> Date: Wed, 18 Mar 2015 03:34:33 +0300 Subject: [PATCH] Method GetTeachersForDiscipline moved to Teachers model --- .../classes/Controller/Student/Index.php | 3 +-- .../classes/Controller/Student/Subject.php | 3 +-- .../application/classes/Model/Student.php | 6 ------ .../application/classes/Model/Teachers.php | 18 +++++++++++------- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/~dev_rating/application/classes/Controller/Student/Index.php b/~dev_rating/application/classes/Controller/Student/Index.php index d9074dc5a..d7e5c353c 100644 --- a/~dev_rating/application/classes/Controller/Student/Index.php +++ b/~dev_rating/application/classes/Controller/Student/Index.php @@ -38,8 +38,7 @@ class Controller_Student_Index extends Controller_UserEnvi { } protected function getTeachersForDiscipline($id) { - $model = new Model_Student; - $teachers = $model->getTeachersForDiscipline($id); + $teachers = Model_Teachers::ofDiscipline($id); $teachersHandled = array(); $i = 0; foreach ($teachers as $teacher) { diff --git a/~dev_rating/application/classes/Controller/Student/Subject.php b/~dev_rating/application/classes/Controller/Student/Subject.php index 5c697a3fa..1931c8f44 100644 --- a/~dev_rating/application/classes/Controller/Student/Subject.php +++ b/~dev_rating/application/classes/Controller/Student/Subject.php @@ -115,8 +115,7 @@ class Controller_Student_Subject extends Controller_UserEnvi { } protected function getTeachersForDiscipline($id) { - $model = new Model_Student; - $teachers = $model->getTeachersForDiscipline($id); + $teachers = Model_Teachers::ofDiscipline($id); $teachersHandled = array(); $i = 0; foreach ($teachers as $teacher) { diff --git a/~dev_rating/application/classes/Model/Student.php b/~dev_rating/application/classes/Model/Student.php index 10b435e93..edd648cc0 100644 --- a/~dev_rating/application/classes/Model/Student.php +++ b/~dev_rating/application/classes/Model/Student.php @@ -14,12 +14,6 @@ class Model_Student extends Model return DB::query(Database::SELECT, $sql)->execute(); } - public function getTeachersForDiscipline($discipline_id) - { - $sql = "CALL `GetTeachersForDiscipline`('$discipline_id'); "; - return DB::query(Database::SELECT, $sql)->execute(); - } - public function getSemesterInfo($id) // TODO: перенести в common.php { $sql = "CALL `GetSemesterInfo`('$id'); "; diff --git a/~dev_rating/application/classes/Model/Teachers.php b/~dev_rating/application/classes/Model/Teachers.php index 652739be3..40c3adec8 100644 --- a/~dev_rating/application/classes/Model/Teachers.php +++ b/~dev_rating/application/classes/Model/Teachers.php @@ -16,11 +16,6 @@ class Model_Teachers extends Model return DB::query(Database::SELECT, $sql)->execute(); } - public function getTeachersForDiscipline($disciplineID) { - $sql = "CALL `GetTeachersForDiscipline`('$disciplineID'); "; - return DB::query(Database::SELECT, $sql)->execute(); - } - public function getTeachersByFaculty($facultyID) { $sql = "CALL `GetTeachersByFaculty`('$facultyID'); "; return DB::query(Database::SELECT, $sql)->execute(); @@ -54,8 +49,17 @@ class Model_Teachers extends Model return new DataArray_Result($list); } - public function forDiscipline($disciplineID, $asConcat = false, $asInitials = false) { - $teachers = $this->getTeachersForDiscipline($disciplineID); + /** + * @param $id int discipline id + * @return Database_Result select from <tt>view_disciplines_teachers</tt> table + */ + public static function ofDiscipline($id) { + $sql = "CALL `GetTeachersForDiscipline`('$id'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + + public static function forDiscipline($disciplineID, $asConcat = false, $asInitials = false) { + $teachers = self::ofDiscipline($disciplineID); $list = array(); foreach ($teachers as $row) { -- GitLab