| View previous topic :: View next topic |
| Author |
Message |
Psyfire Voice
Joined: 05 Nov 2006 Posts: 36
|
Posted: Mon Apr 23, 2007 8:33 pm Post subject: Get a list of a mysql select |
|
|
Hello,
if I type this in phpmyadmin console:
| Code: |
SELECT ps_plr.plrid, ps_plr.uniqueid, ps_plr.rank, ps_plr.skill, ps_plr_profile.name
FROM ps_plr, ps_plr_profile
WHERE allowrank =1
AND ps_plr.uniqueid = ps_plr_profile.uniqueid
ORDER BY skill DESC
LIMIT 10
|
I get this list:
| Code: |
710 STEAM_0:1:1889849 1 1963.16 ()()7
803 STEAM_0:1:12916169 2 1945.60 brasil_fr.
953 STEAM_0:1:859266 3 1881.20 SriQst iZ qL
50 STEAM_0:1:11381583 4 1848.65 Uncle
902 STEAM_0:0:14033485 5 1842.98 The Prophet
976 STEAM_0:1:14352136 6 1834.15 w0ll4k
800 STEAM_0:0:3850505 7 1815.94 EmBri0.Iceman <AdemA>
1001 STEAM_0:1:72535 8 1815.44 busheteeeeeeeeeeeee
944 STEAM_0:1:12625835 9 1781.13 yohan
736 STEAM_0:1:10075317 10 1757.44 JaNoVsKi
|
Thats my output of the select. Now I want to implement this list via a /top10 command in a tcl script.
The problem is, that I dont know how to get this list with this all variables. Can somebody help me? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Apr 24, 2007 8:31 am Post subject: |
|
|
You'll probably have to use the mysqltcl interface, or something similar. If you use mysqltcl, the documentation is available on their homepage. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Psyfire Voice
Joined: 05 Nov 2006 Posts: 36
|
Posted: Tue Apr 24, 2007 12:51 pm Post subject: |
|
|
| I use mysqltcl in my script but I dont know how to create a list that ouputs that data. |
|
| Back to top |
|
 |
w00f Halfop
Joined: 04 Oct 2006 Posts: 49
|
Posted: Wed Apr 25, 2007 11:33 am Post subject: |
|
|
| Code: |
## CONF ##
# trigger to search top10
set srch(top10) "!top10"
# SQL info
set sql(host) "IP"
set sql(user) "USER"
set sql(pass) "PASS-BLA"
set sql(db) "DATABASE-NAME"
set sql(port) "PORT"
## END CONF ##
package require mysqltcl
bind pub - $srch(top10) srh_top
proc srh_top {nick host hand chan arg} {
global sql
set sql(handle) [mysqlconnect -host $sql(host) -user $sql(user) -password $sql(pass) -db $sql(db) -port $sql(port)]
set query [::mysql::query $sql(handle) "SELECT ps_plr.plrid, ps_plr.uniqueid, ps_plr.rank, ps_plr.skill, ps_plr_profile.name FROM ps_plr, ps_plr_profile WHERE allowrank =1 AND ps_plr.uniqueid = ps_plr_profile.uniqueid ORDER BY skill DESC LIMIT 10"]
while {[set row [::mysql::fetch $query]] != ""} {
set plrid [lindex $row 0]
set id [lindex $row 1]
set rank [lindex $row 2]
set skill [lindex $row 3]
set name [lindex $row 4]
putquick "PRIVMSG $chan :\00314\002\[\017\002#$rank\00314\]\002\00314 ~ \002\00307Player\017: $name \00314~\017 \002\00307Skill\017: $skill \00314~\002\00307 iD\017: $id \00314~\002\00307 PLRiD\017: $plrid "
}
::mysql::endquery $query
mysqlclose $sql(handle)
}
putlog "Top10.tcl loaded"
|
didn't tested , but think its ok
Last edited by w00f on Wed Apr 25, 2007 4:17 pm; edited 1 time in total |
|
| Back to top |
|
 |
Psyfire Voice
Joined: 05 Nov 2006 Posts: 36
|
Posted: Wed Apr 25, 2007 12:54 pm Post subject: |
|
|
| Tcl error [srh_top]: invalid command name "::mysql::query" |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Apr 25, 2007 3:45 pm Post subject: |
|
|
Then you're using an older version of mysqltcl. The main difference is older version uses command-names such as mysqlquery while the newer uses namespaces, ie ::mysql::query.
In any case, the docs on their webpage should be enough to atleast get you started...
A good place to start would be the mysqlsel command... _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Psyfire Voice
Joined: 05 Nov 2006 Posts: 36
|
Posted: Fri Apr 27, 2007 8:33 am Post subject: |
|
|
Building Dependency Tree... Done
mysqltcl is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
And now? I got the last version... |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Apr 27, 2007 10:24 am Post subject: |
|
|
Simply... if you've got mysqltcl v3.0, the ::mysql::query command should be available (obviously assuming you've loaded the module properly...)
If you're using any other version, it would be mysqlquery.
Since you failed to mention which version of mysqltcl you're using, I can't tell which syntax would be proper for you... _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Psyfire Voice
Joined: 05 Nov 2006 Posts: 36
|
Posted: Fri Apr 27, 2007 7:21 pm Post subject: |
|
|
I am running definitly 3.02.
The module is loaded of course, otherwise my other mysql scripts wont work and they work 100%. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Apr 27, 2007 9:18 pm Post subject: |
|
|
Well, that error you reported above, does indicate that your module is either broken, or you've failed to load it properly.
You could always check your other scripts, that you say are working, for hints on what you'd have to change to make it work.. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Psyfire Voice
Joined: 05 Nov 2006 Posts: 36
|
Posted: Mon Apr 30, 2007 9:25 pm Post subject: |
|
|
I got it now thanks for the script, works fine.
The problem was that the updater said I got the newest version, but that was not correct.
I deinstalled the current version and installed a new fresh 3.02 now. Strange with this update thing but it works now  |
|
| Back to top |
|
 |
|