Schrift
[thread]10570[/thread]

MySQL und Perl (Seite 7)

Leser: 3


<< |< 1 ... 4 5 6 7 8 >| >> 72 Einträge, 8 Seiten
H3llGhost
 2007-11-07 18:23
#101998 #101998
User since
2007-10-14
60 Artikel
BenutzerIn
[default_avatar]
Hey pq,

danke für den Code!
Der ist fast so wie ich ihn mir vorgestellt hatte, eine Kleinigkeit ist da aber noch.
Siehe Ergebnis:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
$VAR1 = {
'' => {
'use_browser' => undef,
'AddressPort' => undef,
'switch_admins' => undef,
'minplayers' => undef,
'act_players' => '0',
'bombs_defused' => '0',
'serverId' => '2',
'player_admin_command' => undef,
'map_changes' => '0',
'map_ct_wins' => '0',
'address' => '127.0.0.1',
'kills' => '0',
'max_players' => '0',
'bombs_planted' => '0',
'skill_mode' => undef,
'Admins' => undef,
'suicide_penalty' => undef,
'map_ts_shots' => '0',
'map_rounds' => '0',
'name' => 'test',
'map_ct_shots' => '0',
'port' => '27015',
'publicaddress' => undef,
'ba_enabled' => undef,
'map_ts_wins' => '0',
'ts_shots' => '0',
'ts_hits' => '0',
'ignore_bots' => undef,
'auto_ban' => undef,
'broadcasting_command' => undef,
'rounds' => '0',
'broadcasting_player_actions' => undef,
'player_command_osd' => undef,
'suicides' => '0',
'ct_shots' => '0',
'players' => '0',
'public_commands' => undef,
'contact' => undef,
'show_stats' => undef,
'map_ct_hits' => '0',
'player_command_steamid' => undef,
'player_command' => undef,
'min_players_rank' => undef,
'broadcasting_serverdata' => undef,
'ct_hits' => '0',
'broadcasting_command_announce' => undef,
'map_ts_hits' => '0',
'track_server_load' => undef,
'tk_penalty' => undef,
'player_events' => undef,
'broadcasting_command_steamid' => undef,
'ts_wins' => '0',
'hlstats_url' => undef,
'broadcasting_events' => undef,
'headshots' => '0',
'game_type' => undef,
'game' => 'css',
'rcon_password' => 'fuckyou',
'ct_wins' => '0',
'map_started' => '0',
'broadcasting_server_interval' => undef,
'statusurl' => undef,
'act_map' => undef,
'mod' => undef
},
'84.254.65.145:27030' => {
'use_browser' => '0',
'AddressPort' => '84.254.65.145:27030',
'switch_admins' => '0',
'minplayers' => '2',
'act_players' => '2',
'bombs_defused' => '22',
'serverId' => '1',
'player_admin_command' => '',
'map_changes' => '106',
'map_ct_wins' => '11',
'address' => '84.254.65.145',
'kills' => '7185',
'max_players' => '20',
'bombs_planted' => '51',
'skill_mode' => '0',
'Admins' => '0',
'suicide_penalty' => '5',
'map_ts_shots' => '444',
'map_rounds' => '18',
'name' => 'No Escape | Tick 100 | War and Public | Server',
'map_ct_shots' => '425',
'port' => '27030',
'publicaddress' => '',
'ba_enabled' => '0',
'map_ts_wins' => '7',
'ts_shots' => '57435',
'ts_hits' => '10440',
'ignore_bots' => '1',
'auto_ban' => '0',
'broadcasting_command' => 'ma_hlx_psa',
'rounds' => '2733',
'broadcasting_player_actions' => '1',
'player_command_osd' => 'ma_hlx_msa',
'suicides' => '248',
'ct_shots' => '59597',
'players' => '411',
'public_commands' => '1',
'contact' => 'webmaster@battle-stats55.de',
'show_stats' => '1',
'map_ct_hits' => '102',
'player_command_steamid' => '1',
'player_command' => 'ma_hlx_psa',
'min_players_rank' => '0',
'broadcasting_serverdata' => '7',
'ct_hits' => '10378',
'broadcasting_command_announce' => 'ma_hlx_csa',
'map_ts_hits' => '81',
'track_server_load' => '1',
'tk_penalty' => '50',
'player_events' => '1',
'broadcasting_command_steamid' => '1',
'ts_wins' => '1485',
'hlstats_url' => 'http://test2.battle-stats55.de',
'broadcasting_events' => '1',
'headshots' => '2919',
'game_type' => '0',
'game' => 'css',
'rcon_password' => 'stein',
'ct_wins' => '1248',
'map_started' => '1194450974',
'broadcasting_server_interval' => '200',
'statusurl' => undef,
'act_map' => 'cs_italy',
'mod' => 'MANI'
}
};


Der Code dafür ist:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    my $query = "
            SELECT
                    *
            FROM
                    hlstats_Servers
    ";
    my $sth = &doQuery($query);
        
        while (my $row = $sth->fetchrow_hashref()) {
                $g_config_servers{ $row->{AddressPort} } = $row;
        }
        
        use Data::Dumper;
        print Dumper \%g_config_servers;
renee
 2007-11-07 18:24
#101999 #101999
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
H3llGhost+2007-11-07 17:10:14--
Ich möchte gerne das Ergebnis aus dem MySQL-Query genauso wie das hier in der %g_config_servers speichern.
Nur ich weiß nicht genau wie ich das mit einer Schleife mache ...


Nochmal meinen Post ganz genau lesen! Da stand was davon von "Gedanken machen" und "hier skizzieren"...
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
H3llGhost
 2007-11-07 21:48
#102004 #102004
User since
2007-10-14
60 Artikel
BenutzerIn
[default_avatar]
So ...
Ich habe mir nochmal Gedanken gemacht ... xD

Ich möchte ja folgendes Ergebnis haben, wenn ich die Datenbankabfrage durchführe:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$VAR1 = {
'77.237.250.200:27015' => {
'AddressPort' => '77.237.250.200:27015',
'MinPlayers' => '2',
'MasterServerData' => '7',
'PlayerEventsCommand' => 'ma_hlx_psay',
'BroadCastEventsCommandAnnounce' => 'ma_hlx_csay',
'Mod' => 'MANI',
'MinimumPlayersRank' => '0',
'AdminContact' => 'webmaster@battle55-stats.de',
'BroadCastEvents' => '1',
'AutoTeamBalance' => '0',
'SwitchAdmins' => '0',
'EnablePublicCommands' => '1',
'GameType' => '0',
'BroadCastPlayerActions' => '1',
'BroadCastEventsCommandSteamid' => '1',
'PlayerEvents' => '1',
'BroadCastEventsCommand' => 'ma_hlx_psay',
'SkillMode' => '0',
'AutoBanRetry' => '0',
'PlayerEventsCommandSteamid' => '1',
'TrackServerLoad' => '1',
'ShowStats' => '1',
'PlayerEventsCommandOSD' => 'ma_hlx_msay',
'TKPenalty' => '50',
'HLStatsURL' => 'http://test3.battle55-stats.de',
'SuicidePenalty' => '5',
'MasterServerInterval' => '200',
'IgnoreBots' => '1',
'DisplayResultsInBrowser' => '0'
}
};


Dazu habe ich nun den Code noch ein bisschen modifiziert:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    my $query = "
            SELECT
                    *
            FROM
                    hlstats_Servers
    ";
    my $sth = &doQuery($query);
        
        while (my $row = $sth->fetchrow_hashref()) {
                if ($row->{AddressPort} != "")
                {
                        $g_config_servers{ $row->{AddressPort} } = $row;
                }
        }


Nur leider fragt er immer nur den Ersten ab ...
Wie kann ich das erweitern, dass mehr abgefragt werden?
Leider komme ich da nicht weiter ... :(
pq
 2007-11-08 10:52
#102015 #102015
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
wie oft wird den die schleife durchlaufen? wieviele zeilen stehen in der tabelle?
ist AddressPort immer anders? fragen ueber fragen...
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
H3llGhost
 2007-11-08 17:28
#102051 #102051
User since
2007-10-14
60 Artikel
BenutzerIn
[default_avatar]
Ähm ...
Sie sollte zweimal durchlaufen im Moment jedenfalls ...
Je nachdem wie viele Server eingetragen sind, dem entsprechend gibt es auch unterschiedliche AddressPort ...
In anderen Worten es gibt jeden AddressPort nur einmal in der DB.
nepos
 2007-11-08 17:47
#102053 #102053
User since
2005-08-17
1420 Artikel
BenutzerIn
[Homepage] [default_avatar]
Wie wäre es, wenn du dir selbst mal ein wenig Debug-Code einbaust, damit du siehst, ob die Daten so aussehen, wie du dir das erwartest, ob die Schleife entsprechend durchlaufen wird usw.?
Du kannst auch mal mit dem Perl-Debugger (perldebug) auf dein Programm losgehen und dir Schritt für Schritt ansehen, was es genau so tut...
H3llGhost
 2007-11-08 23:12
#102081 #102081
User since
2007-10-14
60 Artikel
BenutzerIn
[default_avatar]
Ähmm ...
Wie baue ich den Code ein?

Ich habe ebend mal perl -d -W -w benutzt und da kommt so viele Informationen!
Ich kann damit aber nichts anfangen ...

Quote
[...] ob die Daten so aussehen, wie du dir das erwartest, ob die Schleife entsprechend durchlaufen wird usw.?


Das sehe ich ja am Endergebnis, dass es nicht funktioniert ... :(
pq
 2007-11-09 00:22
#102087 #102087
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
in die schleife ein print einbauen. ist wirklich einfach.
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
H3llGhost
 2007-11-09 00:23
#102088 #102088
User since
2007-10-14
60 Artikel
BenutzerIn
[default_avatar]
Du meinst das $row ausgeben?
pq
 2007-11-09 00:24
#102089 #102089
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
genau, mit Data::Dumper z.b.
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
<< |< 1 ... 4 5 6 7 8 >| >> 72 Einträge, 8 Seiten



View all threads created 2007-10-14 17:05.