SA-MP Forums Archive
MySQL - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL (/showthread.php?tid=85490)



MySQL - Vince - 07.07.2009

Hey

I'm wondering what works best, good old files or (My)SQL.

I'm currently saving a lot of data in files using dini, namely:
all pickup locations,
all business locations,
all house locations,
all team data (ranks, etc)
all player data

Now, I suppose SQL is faster or something.
I want to convert my gamemode to SQL, but I don't know how SQL works at all.

So will it be worth it? And how do I set it up on Linux (I'm using ServerFFS)?


Re: Files or SQL? - *ToM* - 07.07.2009

If you're going to store many data, definetaly - MySQL.


Re: Files or SQL? - Vince - 07.07.2009

Well, I downloaded a MySQL plugin, gonna take a look at it tomorrow.
Gonna take me a while to understand things like this:

pawn Код:
format(query,sizeof(query),"SELECT * FROM `"TABLENAME"` WHERE Username = '%s' AND Password = md5('%s') LIMIT 1",pName,pass);



Re: Files or SQL? - Chaprnks - 08.07.2009

Quote:
Originally Posted by Vince
Well, I downloaded a MySQL plugin, gonna take a look at it tomorrow.
Gonna take me a while to understand things like this:

pawn Код:
format(query,sizeof(query),"SELECT * FROM `"TABLENAME"` WHERE Username = '%s' AND Password = md5('%s') LIMIT 1",pName,pass);
MySQL takes longer to learn but in the end its worth it. This might help
http://dev.mysql.com/doc/refman/5.0/en/functions.html


Re: Files or SQL? - Westie - 08.07.2009

It doesn't take that much to learn, especially with tools like phpmyadmin to help you create the backend with ease. Why does no one suggest sqlite?


Re: Files or SQL? - Chaprnks - 08.07.2009

Quote:
Originally Posted by /^We(stie|z+[e|a
r)$/ ]
It doesn't take that much to learn, especially with tools like phpmyadmin to help you create the backend with ease. Why does no one suggest sqlite?
Not sure, I never used it so I wouldn't know much.


Re: Files or SQL? - ledzep - 08.07.2009

Quote:
Originally Posted by /^We(stie|z+[e|a
r)$/ ]
It doesn't take that much to learn, especially with tools like phpmyadmin to help you create the backend with ease. Why does no one suggest sqlite?
Dunno about SQLLite, but MySQL has them fancy GUI tools. <3
They probably work with SQLLite anyway though.

But anyway, MySQL is much better than files.
With files, you can only store so much data in them before it takes a long time to read/write from/to them.
MySQL makes it very easy to organize your data.
And it has those perty functions like NOW() and md5()


Re: Files or SQL? - Vince - 08.07.2009

Okay, I've started coding MySQL into my GM, but I get a bunch of errors:
pawn Код:
SetupTable()
{
    new data[4096];
    format(data, sizeof(data),"\
    CREATE TABLE IF NOT EXISTS `%s`(\
    `id`            int(11)     NOT NULL auto_increment PRIMARY KEY,\
    `Username`      varchar(30) NOT NULL, `Password` varchar(50) NOT NULL,\
    `Money`         int(10)     NOT NULL default '0',\
    `Registered`  int(10)   NOT NULL default '0',\
    `LoggedIn`   int(10)        NOT NULL default '0',\
    `TutDone`    int(10)        NOT NULL default '0',\
    `Sex`      int(10)      NOT NULL default '0',\
    `Age`      int(10)      NOT NULL default '0',\ // <= line 455
    `Origin`    int(10)     NOT NULL default '0',\
    `Level`     int(10)     NOT NULL default '0',\
    `AdminLevel`  int(10)       NOT NULL default '0',\
    `Skin`     int(10)      NOT NULL default '0',\
    `Team`     int(10)      NOT NULL default '0',\
    `Leader`    int(10)     NOT NULL default '0',\
    `Rank`     int(10)      NOT NULL default '0',\
    `Cash`     int(10)      NOT NULL default '0',\
    `Bank`     int(10)      NOT NULL default '0',\
    `DrivingLic`  int(10)       NOT NULL default '0',\
    `FlyingLic`   int(10)       NOT NULL default '0',\
    `SailingLic`  int(10)       NOT NULL default '0',\
    `GunLic`    int(10)     NOT NULL default '0',\
    `Drugs`     int(10)     NOT NULL default '0',\
    `DrugPacks`   int(10)       NOT NULL default '0',\
    `Mats`     int(10)      NOT NULL default '0',\
    `MatPacks`    int(10)       NOT NULL default '0')\
    "
,TABLENAME);
    mysql_query(data);
    return 1;
}
Код:
D:\Documents and Settings\Vince\Mijn Documenten\SA-MP SERVER\gamemodes\rrp.pwn(455) : error 075: input line too long (after substitutions)
D:\Documents and Settings\Vince\Mijn Documenten\SA-MP SERVER\gamemodes\rrp.pwn(456) : error 037: invalid string (possibly non-terminated string)
D:\Documents and Settings\Vince\Mijn Documenten\SA-MP SERVER\gamemodes\rrp.pwn(456) : error 017: undefined symbol "CREATE"
D:\Documents and Settings\Vince\Mijn Documenten\SA-MP SERVER\gamemodes\rrp.pwn(456) : error 017: undefined symbol "TABLE"
D:\Documents and Settings\Vince\Mijn Documenten\SA-MP SERVER\gamemodes\rrp.pwn(456) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.



Re: MySQL - Andom - 08.07.2009

I've got the same error, but i deleted SetupTabled, just created by yourself and don't let samp do it for you.