Please verify you are human

[R] MySQL-Function
  Register for your free account! | Forgot your password?
Rust Cheats

You last visited: Today at 13:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[R] MySQL-Function

Discussion on [R] MySQL-Function within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.

Reply
 
Old   #1
 
Mijago's Avatar
 
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(strdelimmaxNb)
    if 
str == nil then return str end
    
if string.find(strdelim) == 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 partpos in string.gfind(strpat) 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(strlastPosend
    
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')) endos.remove(fi);
    for 
2table.getn(t) do table.foreach(t[i],function(a,b)
        
out[i-1]               = out[i-1] or {}
        
out[i-1][a]            = tonumber(b) or or 'NULL'
        
out[t[1][a]]           = out[t[1][a]] or {}
        
out[t[1][a]][i-1]      = tonumber(b) or or 'NULL'
    
endend
    
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!
Mijago is offline  
Thanks
27 Users
Old 08/12/2012, 22:59   #2
 
.Active's Avatar
 
elite*gold: 0
Join Date: Mar 2011
Posts: 291
Received Thanks: 73
Love you
mijaja <3
.Active is offline  
Old 08/12/2012, 22:59   #3
 
Pаylasici's Avatar
 
elite*gold: 99
Join Date: Aug 2009
Posts: 4,295
Received Thanks: 5,091
Super gemacht Schatz.
Pаylasici is offline  
Old 08/12/2012, 23:00   #4
 
αddι's Avatar
 
elite*gold: 21
Join Date: Jan 2010
Posts: 640
Received Thanks: 532
Uuuuh danke, extra für mich? xD

€: Ok habs verstanden
αddι is offline  
Old 08/12/2012, 23:02   #5

 
xXKimariXx's Avatar
 
elite*gold: 5
Join Date: Aug 2011
Posts: 1,130
Received Thanks: 512
Danke Mijago^^
xXKimariXx is offline  
Old 08/12/2012, 23:07   #6
 
.αpeх''s Avatar
 
elite*gold: 244
Join Date: Jun 2010
Posts: 602
Received Thanks: 471
Geil *o*

Wie immer geniales Zeig von dir
.αpeх' is offline  
Old 08/12/2012, 23:09   #7
 
elite*gold: 0
Join Date: Oct 2009
Posts: 382
Received Thanks: 161
Thank You Mijago
vpser is offline  
Old 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
x3DQ is offline  
Old 08/12/2012, 23:47   #9
 
Mijago's Avatar
 
elite*gold: 191
Join Date: May 2009
Posts: 1,214
Received Thanks: 2,598
Quote:
Originally Posted by x3DQ View Post
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.
Mijago is offline  
Old 08/13/2012, 00:04   #10
 
elite*gold: 0
Join Date: Aug 2012
Posts: 84
Received Thanks: 9
achso
x3DQ is offline  
Old 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 :/
poowaa is offline  
Old 08/16/2012, 00:31   #12
 
Mijago's Avatar
 
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()....
Mijago is offline  
Old 12/09/2012, 20:02   #13
 
Mijago's Avatar
 
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')) endos.remove(fi);
    for 
2table.getn(t) do table.foreach(t[i],function(a,b)
        
out[i-1]               = out[i-1] or {}
        
out[i-1][a]            = tonumber(b) or or 'NULL'
        
out[t[1][a]]           = out[t[1][a]] or {}
        
out[t[1][a]][i-1]      = tonumber(b) or or 'NULL'
    
endend
    
return out
end 
MySQL51: --e=""
MySQL55: -e""
Mijago is offline  
Old 12/10/2012, 15:29   #14
 
elite*gold: 0
Join Date: Aug 2011
Posts: 17
Received Thanks: 1
Where we put this code pls?
agronaque512 is offline  
Old 12/10/2012, 18:41   #15
 
ThinSmoke's Avatar
 
elite*gold: 49
Join Date: Sep 2008
Posts: 906
Received Thanks: 600
Quote:
Originally Posted by Mijago View Post
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')) endos.remove(fi);
    for 
2table.getn(t) do table.foreach(t[i],function(a,b)
        
out[i-1]               = out[i-1] or {}
        
out[i-1][a]            = tonumber(b) or or 'NULL'
        
out[t[1][a]]           = out[t[1][a]] or {}
        
out[t[1][a]][i-1]      = tonumber(b) or or 'NULL'
    
endend
    
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 :-)
ThinSmoke is offline  
Reply


Similar Threads 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.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.