Пример #1
0
/**
 * Gets the session info by id
 * @param int       Session ID
 * @return array    information of the session
 */
function api_get_session_info($session_id, $add_extra_values = false)
{
    $data = array();
    if (!empty($session_id)) {
        $session_id = intval($session_id);
        $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
        $sql = "SELECT * FROM {$tbl_session} WHERE id = {$session_id}";
        $result = Database::query($sql);
        if (Database::num_rows($result) > 0) {
            $data = Database::fetch_array($result, 'ASSOC');
            if ($add_extra_values) {
                $extra_field_values = new ExtraField('session');
                $data['extra_fields'] = $extra_field_values->get_handler_extra_data($session_id);
            }
        }
    }
    return $data;
}