Skip to content

Database

Adrian Preuß edited this page Jan 18, 2021 · 2 revisions

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

💥 Create a Database-Table

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

➕ Insert an Entry to the Database-Table

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

✖️ Delete an Entry on the Database-Table

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

📄 Fetch a single Record from the Database-Table

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

print(single);

📖 Fetch all Records from the Database-Table

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

print(all);

💡 Count results from the Database-Table

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

print(count);