Database - Joe91/fun-bots GitHub Wiki

If you contribute to fun-bots please don't use the SQL Library from Venice Unleashed. We has provided an own class named Database.

:boom: Create a Database-Table

Database:createTable('TestName', {
	DatabaseField.ID,
	DatabaseField.Text,
	DatabaseField.Integer,
	DatabaseField.Time
}, {
	'ID',
	'Key',
	'Value',
	'Time'
});

:heavy_plus_sign: Insert an Entry to the Database-Table

local lastID = Database:insert('TestName', {
	ID	= DatabaseField.NULL,
	Key	= 'Hello',
	Value	= 'World',
	Time	= Database:now()
});

:heavy_multiplication_x: Delete an Entry on the Database-Table

Database:delete('TestName', {
	ID	= 0
});

:page_facing_up: Fetch a single Record from the Database-Table

local single = Database:single('SELECT * FROM `TestName` WHERE `Key`=\'Hello\'');

print(single);

:book: Fetch all Records from the Database-Table

local all = Database:fetch('SELECT * FROM `TestName` WHERE `Key`=\'Hello\'');

print(all);

:bulb: Count results from the Database-Table

local count = Database:count('SELECT * FROM `TestName` WHERE `Key`=\'Hello\'');

print(count);