Skip to content
Xandaros edited this page Sep 12, 2013 · 4 revisions

Evolve2 allows for different ways to store your data.
To install and activate a persistence plugin, simply put it in persistence/ and change the id of the plugin to be used in databaseConfig.lua

To create a persistence plugin, you need to call evolve:registerPersistence, which takes a table as argument.
The table looks as follows:
(Please note that every persistence plugin must be convertible to MySQL and each table must contain a numeric primary key. [combined works])

It contains a value "ID" with the identifier for the plugin. (What you need to put in databaseConfig.lua)
It contains the following "methods":

begin(): optional. Prepares the backend for lots of consecutive queries. Does not execute queries.
commit(): optional. Executed the queries that came after begin.

createTable(table, tableData, primaryKey): Creates a table. Makes the columns listed in primaryKey(an array-like table or a string) the primary key. Implementation of primaryKey is optional, but highly recommended.
dropTable(table): Deletes the table
addColumn(table, name, type): Adds a column to the table
dropColumns(table, columns): Removes columns from the table
modifyColumnTypes(table, columns, type): Modifies the type of columns
renameTable(table, newName): Renames the table

insert(table, data): Inserts data into the specified table.
get(table, filter): Gets data from the database.
delete(table, filter): Deletes every entry that matches the filter.
update(table, data, filter): Updates every entry that matches the filter.

table is a string.
tableData is a table: {column_1=type_1, column_2=type_2, and so on} Type can be, for example, VARCHAR or INTEGER. Valid types are: TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT, DECIMAL, FLOAT, DOUBLE and VARCHAR
Make sure all of them are supported. For more information, see: http://dev.mysql.com/doc/refman/5.0/en/data-type-overview.html
Please note that these are not all possible Datatypes in MySQL. The others cannot be used for the sake of other persistence plugins.

data is a table:
{column_1=value_1, column_2=value_2, and so on}

filter is a table:
Variation1: {column_1=value_1, column_2=value_2, and so on} checks for equality
Variation2: {column_1={value_1, flag_1}, column_2={value_2, flag_2}, and so on} checks depending on flag.
Flag is an integer. <1 and >7 will result in an error. 1 checks for equality. 2 - less, 4 - greater. Everything else is a combination: 3 - less or equal, 5 - greater or equal, 6 - not equal. 7 is the only exception, this is the LIKE operator from SQL. It is not optional. If the backend does not support it, you have to implement it yourself.
The variations can be mixed, as well.

Clone this wiki locally