Jump to content

Data saving. Best way?


SayMyName

Recommended Posts

Depends what type of data you want to store, stats and gameprogress could be stored in a MySQL server obviously, the advantages of that is the ability to sync data across multiple servers without having to rewrite anything, it just works and the simplicity in case you wish to show your players stats online on a php powered website for instance.

For data related to elements that needs to be accessed on many different places (server/client/shared) element data is the obvious choice, if I remember right it's also cleaned up from the memory as soon the element is destroyed, otherwise that functionality can easily be accomplished by a single function triggering on element destroy bound to root element.

Account data and execute SQL query functions is actually those built in SQLite databases register.db and internal.db. Just like MySQL it's a quick and efficient way to store large amount of server side data. SQLite can only be used by one process at once as it's stored in a local file so use it only if you don't plan to access the data from any other service or server than your MTA server.

XML is slow but could be useful for client side settings, for instance if you have a login panel with a checkbox "remember me" you could save the data from the two edit fields in an xml file, encrypt the data first for secure storage or keep it unencrypted to solve the problem with lost passwords in a basic way.

Link to comment
MySQL provides flexibility, so I say MySQL.

What about SQL injection .

You can simply use the db functions provided by MTA and you're on the clear. Input is never processed, just passed as parameters. Prepared statements ftw.

What about SQL injection .

SQL injections works on SQLite too, in both cases you just need to escape the input string and get rid of symbols like these: '=&"*?}{ just to mention a few.

You don't need to get rid of anything. That's against the whole idea of saving data. You're manipulating the end result.

The only case where I would manipulate data is when I need to display it on a website. Stripping tags, then converting special characters into HTML entities and trimming both ends of the string. Makes it clean and simple.

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