Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-9536

Small improvement for query against sessions table in acp_users.php

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Trivial Trivial
    • 3.0.8-RC1
    • 3.0.7-PL1
    • ACP
    • None

      In includes/acp/acp_users.php there is this query (twice).

      		// Generate content for all modes
      		$sql = 'SELECT u.*, s.*
      			FROM ' . USERS_TABLE . ' u
      				LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
      			WHERE u.user_id = ' . $user_id . '
      			ORDER BY s.session_time DESC';
      		$result = $db->sql_query($sql);
      		$user_row = $db->sql_fetchrow($result);
      		$db->sql_freeresult($result);
      

      Note that only row is being fetched.

      If it is guaranteed that only one row matches the query criteria, the ORDER BY can be omitted.
      If there can be more than one row, $db->sql_query_limit($sql, 1); can be used.

            bantu Andreas Fischer [X] (Inactive)
            bantu Andreas Fischer [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: