Fixed missing $DB in get_records_sql function