Ejemplo n.º 1
0
    public function addTeacherToСourse($course_id, $teachers)
    {
        $smnt = MyDatabase::db()->prepare('
DELETE FROM course_user
WHERE course_user.is_admin = 1 AND course_user.course_id = :course_id;
DELETE FROM course_user
WHERE course_user.course_id = :course_id AND course_user.user_id IN (:teacher);
        ');
        try {
            $smnt->execute(array('teacher' => implode(',', $teachers), 'course_id' => $course_id));
            $smnt->closeCursor();
        } catch (PDOException $ex) {
            return false;
        }
        $smnt2 = MyDatabase::db()->prepare('
            INSERT INTO course_user(user_id,course_id,is_admin)
            VALUES(:user_id,:course_id,1)');
        foreach ($teachers as $teacher) {
            try {
                $smnt2->execute(array('user_id' => $teacher, 'course_id' => $course_id));
            } catch (PDOException $ex) {
                return false;
            }
        }
        return true;
    }
Ejemplo n.º 2
0
 public function reportBestUniversityForScale($scale)
 {
     try {
         $smnt = MyDatabase::db()->prepare("call procedure_report_{$scale}_best_university()");
         $smnt->execute();
         return $smnt->fetchAll();
     } catch (Exception $e) {
         return null;
     }
 }
Ejemplo n.º 3
0
 public function reportNewUserForScale($scale)
 {
     try {
         $smnt = MyDatabase::db()->prepare(" call procedure_report_new_user_{$scale}()");
         $smnt->execute();
         return $smnt->fetchAll();
     } catch (Exception $e) {
         return null;
     }
 }
Ejemplo n.º 4
0
 public function findAllAsArrayForFrontendPersonal($user_id)
 {
     try {
         $smnt = MyDatabase::db()->prepare(" SELECT table2.*\nFrom course_user\nINNER JOIN\n(\nSelect `course`.`id` AS `id` , `course`.title as `title`  ,\n`course_original_type`.`title` as `type`, `university`.`title` as  `university`,\nCOUNT(`User`.`id`) as `counts`\nFROM  `course`\nINNER JOIN `course_original_course` ON `course_original_course`.`id` = `course`.`original_course_id`\nINNER JOIN university ON university.id = course_original_course.university_id\nINNER JOIN course_original_type ON course_original_type.id = course_original_course.type_id\nLEFT JOIN course_user ON course.id = course_user.course_id\nLEFT JOIN `User` ON course_user.user_id = User.id\nGROUP BY course.id, course.title, course_original_type.title, university.title\n    ) as table2\nON course_user.course_id = table2.id\nWHERE course_user.user_id = :user_id");
         $smnt->execute(array('user_id' => $user_id));
         return $smnt->fetchAll();
     } catch (Exception $e) {
         return null;
     }
 }