05-10-2015, 12:21 AM
(05-08-2015, 05:15 PM)xoft Wrote: You'll need at least a basic crash-course in general database design and SQL language, those are available all over the Net. Once you have an idea of how to structure your data tables, and how to query them for information and how to insert information into them, you'll be able to work with the API rather naturally. You basically use just 3 functions from the sqlite API - open(), close() and exec(). Open and close are easy - they just open and close the database files. Exec is where all the important stuff happens - it executes ANY sql code.
Of course, in time you'll want to upgrade to using prepared statements. These are what most plugins nowadays use. Basically with statements you say "I want to execute this sql code several times, each time the same statement but with different data. And give me results one at a time".
I'd recommend having a look at the Gallery plugin's Storage_SQLite file, it implements the entire SQLite storage mechanism for the Gallery plugin:
https://github.com/mc-server/Gallery/blo...SQLite.lua
A good example of working with the database is the RemoveArea() function: https://github.com/mc-server/Gallery/blo...#L835-L871
It inserts data to one table and removes data from two other tables.
The LoadAllPlayerAreas() function, on the other hand, queries the database for data in a basic way: https://github.com/mc-server/Gallery/blo...#L835-L871
Alright, i'll give things a try.