Jump to content

SQL & XML - Simple Questions


'LinKin

Recommended Posts

Hello,

I'm planning to make some stats for race. I've seen that people say that SQL is way better than using a .xml file to save the data.

So I've some questions;

1. I think I must create a table (executeSQLCreateTable) once the resource is started (onResourceStart). But, I see that way will create another NEW table everytime the resource is started (Probably a server's restart). Meaning that the 'old' data will be lost. How can I make it so that the data is truly safe?

2. If I use XML as an alternative way, when the file becomes bigger (too many players' data) will the server lag? Any consequence?

3. If I choose to work with XML, if I wanted to move the data from the current server to a new one, copy-pasting the resource into the new server will allow me to move the data? (Of course the script must have a fuction to load player's data from the .xml file).

4. Similar to 3, if I choose to work with SQL, how can I move the data from the current server to another one?

5. Has the syntax of SQL changed?

Because in the wiki I see this example:

executeSQLCreateTable ( "players", "clothes_head_texture TEXT, clothes_head_model TEXT, player TEXT" )

But in other script, I see something like:

executeSQLCreateTable ( "players", "clothes_head_texture STRING, clothes_head_model STRING, player STRING" )

Or both ways are correct?

EDIT: I just saw that some updates were done. Now mostly of SQL functions are called with executeSQLQuery

Regards,

LinKin.

Edited by Guest
Link to comment

XML is more secure, in my opinion setElementData = SQL. XML is a file which you can open/close/save any time and XML doesn't lagg.

3. If I choose to work with XML, if I wanted to move the data from the current server to a new one, copy-pasting the resource into the new server will allow me to move the data? Yes.

_____________________________________________________________________________________________________

Also, its really easy to use XML. Let me know if you need help.

Link to comment

setElementData has nothing to do with SQL.

XML is not more secure then SQL.

Now, for the SQL questions.

1. executeSQLCreateTable is deprached.

executeSQLQuery 

This function is used to execute any SQL query on MTA's internal database.

To create a table, use:

executeSQLQuery("CREATE TABLE IF NOT EXISTS tablename (column1 type1, column2 type2, column3 type3)") 

Search on google for SQL data types.

4. Moving data with SQL is a bit more complicated, you'd need to open your registry.db file from mods/deathmatch using SQLite browser:

http://sourceforge.net/projects/sqlitebrowser/

Then, you'd need to export the table and then import it to the registry.db of the other server.

5. SQL syntax hasn't changed in some time, there's no type called "STRING" so, "TEXT" is the correct one.

All the bigger MTA servers use SQL, most of them even have an MySQL server running on the same host because it's faster then MTA's SQLite.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...