Skip to content

Commit

Permalink
Improve query see BT#12824
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed May 29, 2017
1 parent 4893a98 commit 151a927
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions main/inc/lib/sessionmanager.lib.php
Expand Up @@ -3370,7 +3370,7 @@ public static function get_sessions_followed_by_drh(
/**
* Get sessions followed by human resources manager
* @param int $userId
* @param int $status Optional
* @param int $status DRH Optional
* @param int $start
* @param int $limit
* @param bool $getCount
Expand Down Expand Up @@ -3399,10 +3399,9 @@ public static function getSessionsFollowedByUser(
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

$userId = intval($userId);
$userId = (int) $userId;

$select = " SELECT DISTINCT * ";

if ($getCount) {
$select = " SELECT count(DISTINCT(s.id)) as count ";
}
Expand All @@ -3412,7 +3411,7 @@ public static function getSessionsFollowedByUser(
}

$limitCondition = null;
if (!empty($start) && !empty($limit)) {
if (!is_null($start) && !is_null($limit)) {
$limitCondition = " LIMIT ".intval($start).", ".intval($limit);
}

Expand All @@ -3423,7 +3422,7 @@ public static function getSessionsFollowedByUser(
$whereConditions = null;
$sessionCourseConditions = null;
$sessionConditions = null;
$sessionQuery = null;
$sessionQuery = '';
$courseSessionQuery = null;

switch ($status) {
Expand Down Expand Up @@ -3467,7 +3466,8 @@ public static function getSessionsFollowedByUser(
$subQuery = $sessionQuery.$courseSessionQuery;

$sql = " $select FROM $tbl_session s
INNER JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
INNER JOIN $tbl_session_rel_access_url a
ON (s.id = a.session_id)
WHERE
access_url_id = ".api_get_current_access_url_id()." AND
s.id IN (
Expand Down

0 comments on commit 151a927

Please sign in to comment.