|
You last visited: Today at 13:18
Advertisement
[R] MySQL-Function
Discussion on [R] MySQL-Function within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.
08/12/2012, 22:59
|
#1
|
elite*gold: 191
Join Date: May 2009
Posts: 1,214
Received Thanks: 2,598
|
[R] MySQL-Function
Da die derzeitigen MySQL-Funktionen "etwas" veraltet sind, hier mal eine neue:
PHP Code:
function split(str, delim, maxNb) if str == nil then return str end if string.find(str, delim) == nil then return { str } end if maxNb == nil or maxNb < 1 then maxNb = 0 end local result = {} local pat = "(.-)" .. delim .. "()" local nb = 0 local lastPos for part, pos in string.gfind(str, pat) do nb = nb + 1 result[nb] = part lastPos = pos if nb == maxNb then break end end if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos) end return result end
mysql_query = function(query) if not pre then local rt = io.open('CONFIG','r'):read('*all') pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4') end math.randomseed(os.time()) local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{} os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- für MySQL51 -- os.execute('mysql '..pre..' -e='..string.format('%q',query)..' > '..fi) -- für MySQL55 for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi); for i = 2, table.getn(t) do table.foreach(t[i],function(a,b) out[i-1] = out[i-1] or {} out[i-1][a] = tonumber(b) or b or 'NULL' out[t[1][a]] = out[t[1][a]] or {} out[t[1][a]][i-1] = tonumber(b) or b or 'NULL' end) end return out end
Ich habe die Funktion absichtlich kurz gehalten (verglichen mit meiner alten Version ist die hier ein Witz). Sie liest die Zugangsdaten aus der CONFIG-Datei des Cores aus.
Neuer Output:
Output[Zeile][Reihe]
###
Jetzt auch (fast) Abwärtskompatibel
Output.Spaltenname[zeile]
###
Danke an:
Paylasici für den Anstoß, die Userrechte aus der CONFIG-Datei zu lesen
αddι für das ständige generve, ich solle die MySQL-Func überarbeiten
.Active für die Unterhaltung und das Ablenken xD
Und natürlich an mein Prinzesschen ♥.Mercy.♥ für die viele gute Laune
lg Mijago
### Update
Nun Abwärtskompatibel zu meiner Questlib!
Bei MySQL55 müsst ihr ab und an --e= durch -e ersetzen!
|
|
|
08/12/2012, 22:59
|
#2
|
elite*gold: 0
Join Date: Mar 2011
Posts: 291
Received Thanks: 73
|
Love you
mijaja <3
|
|
|
08/12/2012, 22:59
|
#3
|
elite*gold: 99
Join Date: Aug 2009
Posts: 4,295
Received Thanks: 5,091
|
Super gemacht Schatz.
|
|
|
08/12/2012, 23:00
|
#4
|
elite*gold: 21
Join Date: Jan 2010
Posts: 640
Received Thanks: 532
|
Uuuuh danke, extra für mich? xD
€: Ok habs verstanden
|
|
|
08/12/2012, 23:02
|
#5
|
elite*gold: 5
Join Date: Aug 2011
Posts: 1,130
Received Thanks: 512
|
Danke Mijago^^
|
|
|
08/12/2012, 23:07
|
#6
|
elite*gold: 244
Join Date: Jun 2010
Posts: 602
Received Thanks: 471
|
Geil *o*
Wie immer geniales Zeig von dir
|
|
|
08/12/2012, 23:09
|
#7
|
elite*gold: 0
Join Date: Oct 2009
Posts: 382
Received Thanks: 161
|
Thank You Mijago
|
|
|
08/12/2012, 23:32
|
#8
|
elite*gold: 0
Join Date: Aug 2012
Posts: 84
Received Thanks: 9
|
Was bringt das blicks net D:
Aber weil alle THX geben bekommst du auch eins von mir
|
|
|
08/12/2012, 23:47
|
#9
|
elite*gold: 191
Join Date: May 2009
Posts: 1,214
Received Thanks: 2,598
|
Quote:
Originally Posted by x3DQ
Was bringt das blicks net D:
Aber weil alle THX geben bekommst du auch eins von mir 
|
Dass du in Quests auf die MySQL-Datenbank des Servers zugreifen kannst 
Eigendlich nur für fortgeschrittene Questwriter nützlich.
|
|
|
08/13/2012, 00:04
|
#10
|
elite*gold: 0
Join Date: Aug 2012
Posts: 84
Received Thanks: 9
|
achso
|
|
|
08/15/2012, 23:14
|
#11
|
elite*gold: 0
Join Date: May 2009
Posts: 20
Received Thanks: 3
|
Thanks Mijago it's cool.
I can use it with UPDATE and INSERT INTO.
Can u help me?
Code:
quest teszteljunk begin
state start begin
when 53001.use begin
asd = mysql_query("SELECT name FROM player.player WHERE id="..pc.get_player_id()..";")
say(""..asd.."")
say(""..asd[1].."")
say(""..asd[1][1].."")
end
end
end
What's wrong? I can't write down the output :/
|
|
|
08/16/2012, 00:31
|
#12
|
elite*gold: 191
Join Date: May 2009
Posts: 1,214
Received Thanks: 2,598
|
asd[1][1]
or
asd.name[1]
or simply pc.get_name()....
|
|
|
12/09/2012, 20:02
|
#13
|
elite*gold: 191
Join Date: May 2009
Posts: 1,214
Received Thanks: 2,598
|
Fix für: # mysql: ambiguous option
Habe mal die Funktion aus der Questlib hier eingefügt.
Und unten den Fix angefügt, weshalb viele Denken, diese Lib geht nicht (leute, der Fix ist seit Monaten bekannt xD)
Er ist auch in der Funktion mittlerweile.
PHP Code:
mysql_query = function(query) if not pre then local rt = io.open('CONFIG','r'):read('*all') pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4') end math.randomseed(os.time()) local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{} os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- für MySQL51 -- os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) -- für MySQL55 for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi); for i = 2, table.getn(t) do table.foreach(t[i],function(a,b) out[i-1] = out[i-1] or {} out[i-1][a] = tonumber(b) or b or 'NULL' out[t[1][a]] = out[t[1][a]] or {} out[t[1][a]][i-1] = tonumber(b) or b or 'NULL' end) end return out end
MySQL51: --e=""
MySQL55: -e""
|
|
|
12/10/2012, 15:29
|
#14
|
elite*gold: 0
Join Date: Aug 2011
Posts: 17
Received Thanks: 1
|
Where we put this code pls?
|
|
|
12/10/2012, 18:41
|
#15
|
elite*gold: 49
Join Date: Sep 2008
Posts: 906
Received Thanks: 600
|
Quote:
Originally Posted by Mijago
Habe mal die Funktion aus der Questlib hier eingefügt.
Und unten den Fix angefügt, weshalb viele Denken, diese Lib geht nicht (leute, der Fix ist seit Monaten bekannt xD)
Er ist auch in der Funktion mittlerweile.
PHP Code:
mysql_query = function(query)
if not pre then
local rt = io.open('CONFIG','r'):read('*all')
pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4')
end
math.randomseed(os.time())
local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{}
os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- für MySQL51
-- os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) -- für MySQL55
for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi);
for i = 2, table.getn(t) do table.foreach(t[i],function(a,b)
out[i-1] = out[i-1] or {}
out[i-1][a] = tonumber(b) or b or 'NULL'
out[t[1][a]] = out[t[1][a]] or {}
out[t[1][a]][i-1] = tonumber(b) or b or 'NULL'
end) end
return out
end
MySQL51: --e=""
MySQL55: -e""
|
Wer wirklich mit dieser Funktion arbeiten will sollte wenigstens mySQL Grundkentnisse haben und dem wäre das auch alleine klar geworden.
"Copy & Paste "nutzung ist doch langweilig.
Nunja, gute Arbeit und sehr sinnige Nutzung :-)
|
|
|
 |
|
Similar Threads
|
MySQL - L server through socket '/tmp/mysql.sock' (38) failed, retrying in 5 secon
06/28/2012 - Metin2 Private Server - 2 Replies
Hi EPvP
I have one problem whit my server. I install a new game + db and i start him
L server through socket '/tmp/mysql.sock' (38)
failed, retrying in 5 secondsSuccess HOTBACKUP
Why?
|
[VIP-function] ToxicSYS [VIP-function]
08/14/2010 - WarRock Hacks, Bots, Cheats & Exploits - 1 Replies
heeeey E-pvpers :pimp:
this is a new hack by TSYS
Status : UNDETECTED
Functions (VIDEO) :
YouTube - WarRock - Bikini event VIP hack
|
MySQL Navicat 1130-Host'5.xxx.xx.xxx' is not allowed to connect to the MySQL Server
08/07/2010 - Metin2 Private Server - 14 Replies
Hallo com,
ich habe ein Problem mit Navicat. Undzwar habe ich diesen Fehler hier : "1130-Host'5.xxx.xx.xxx' is not allowed to connect to the MySQL Server" seid gestern.
Ich dachte mir mal ich änder mein Navicat Passwort um... Als ich dies getan habe, und meinen Server rebootet habe und Navicat neugestartet habe, und ich mich wieder in Navicat einloggen wollte kam diese Fehlermeldung. Nun habe ich das Problem das ich mich nicht mehr mit Navicat connecten kann. Habe schon alles versucht...
|
All times are GMT +1. The time now is 13:19.
|
|