Skip to content
Snippets Groups Projects
Commit 68a49f91 authored by PavelBegunkov's avatar PavelBegunkov
Browse files

add sql: get list of teachers for all student's disciplines (student index page)

parent eb4e8c70
Branches
Tags
No related merge requests found
...@@ -446,6 +446,56 @@ BEGIN ...@@ -446,6 +446,56 @@ BEGIN
view_teachers.FirstName ASC; view_teachers.FirstName ASC;
END // END //
DROP PROCEDURE IF EXISTS GetTeachersListForStudent//
CREATE PROCEDURE `GetTeachersListForStudent` (
IN `pStudentID` INT,
IN `pSemesterID` INT
) NO SQL
BEGIN
DECLARE vStudentGroup INT DEFAULT -1;
SET vStudentGroup = GetStudentGroup(pStudentID, pSemesterID);
# select all disciplines for user
CREATE TEMPORARY TABLE IF NOT EXISTS tDisciplines AS (
SELECT disc2.DisciplineID
FROM (
SELECT disc1.DisciplineID,
COALESCE(disc1.Type) AS 'Type'
FROM (
SELECT disciplines_students.DisciplineID,
disciplines_students.Type
FROM `disciplines_students`
WHERE disciplines_students.StudentID = pStudentID
UNION
SELECT disciplines_groups.DisciplineID,
NULL AS 'Type'
FROM `disciplines_groups`
WHERE disciplines_groups.GroupID = vStudentGroup
) AS disc1
INNER JOIN `disciplines` ON disciplines.ID = disc1.DisciplineID
WHERE disciplines.SemesterID = pSemesterID
GROUP BY disc1.DisciplineID
) AS disc2
WHERE NOT disc2.Type <=> 'detach'
);
SELECT tDisciplines.DisciplineID,
GROUP_CONCAT(
CONCAT(teachers.LastName, ' ', teachers.FirstName, ' ', teachers.SecondName)
ORDER BY teachers.ID = disciplines.AuthorID DESC,
teachers.LastName ASC,
teachers.FirstName ASC
SEPARATOR ';'
) AS 'FullNameList'
FROM tDisciplines
INNER JOIN `disciplines` ON disciplines.ID = tDisciplines.DisciplineID
LEFT JOIN `disciplines_teachers` ON disciplines_teachers.DisciplineID = tDisciplines.DisciplineID
INNER JOIN `teachers` ON teachers.ID = disciplines_teachers.TeacherID
GROUP BY tDisciplines.DisciplineID
ORDER BY tDisciplines.DisciplineID;
END //
# get teachers, that don't teach course # get teachers, that don't teach course
......
...@@ -250,7 +250,17 @@ class Kohana_Database_Query { ...@@ -250,7 +250,17 @@ class Kohana_Database_Query {
} }
// Execute the query // Execute the query
$start = microtime(true);
$result = $db->query($this->_type, $sql, $as_object, $object_params); $result = $db->query($this->_type, $sql, $as_object, $object_params);
$end = microtime(true);
$btrc = debug_backtrace();
$last = array(
"file" => $btrc[0]['file'],
"sql" => $sql,
"dtime" => ($end - $start) * 1000
);
echo Debug::vars($last);
if (isset($cache_key) AND $this->_lifetime > 0) if (isset($cache_key) AND $this->_lifetime > 0)
{ {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment