示例#1
0
 private static function setCourseUserSelection(&$constraints = array())
 {
     //"(select count( * ) from users_to_courses uc, users u where uc.courses_ID=c.id and u.archive=0 and u.active=1 and uc.archive=0 and u.login=uc.users_LOGIN and u.user_type='student') as num_students";
     if (empty($constraints['table_filters'])) {
         return "(select count( * ) from users_to_courses uc, users u where uc.courses_ID=c.id and u.archive=0 and u.active=1 and uc.archive=0 and u.login=uc.users_LOGIN and u.user_type='student') as num_students";
     } else {
         list($where, $limit, $orderby) = EfrontCourse::convertCourseUserConstraintsToSqlParameters($constraints);
         $from = "users_to_courses uc, users u";
         $from = EfrontCourse::appendTableFiltersUserConstraints($from, $constraints);
         $where[] = "uc.courses_ID=c.id";
         $where[] = "u.archive=0";
         $where[] = "u.login=uc.users_LOGIN";
         $where[] = "u.user_type='student'";
         unset($constraints['table_filters']);
         // to avoid using the filters again in courses....
         return "(select count(*) FROM " . $from . " WHERE " . implode(" AND ", $where) . ") as num_students";
     }
 }