CSQL stands for "Cs2d Structured Query Language" which is a professional method that supports 4 main order(Select, Insert, Update, Delete).
Due to lack of time, i just explain how it works.Installation 
Install(...)
create some folder needed for storing data files:
--> CSQL
--> CSQL --> Databases
--> CSQL --> Backup
--> CSQL --> System
Example :
createDatabase(string DB_NAME)
create database folder in CSQL --> Databases -- > DB_NAME
Example :
selectDatabase(string DB_NAME)
select a database as active one.
Example :
createTable(TBL_NAME, COULMN_1, COULMN_2, COULMN_3, ....)
create table file in CSQL --> Databases -- > ACTIVE_DB_NAME --> TBL_NAME.ctbl
Example :

Install(...)create some folder needed for storing data files:
--> CSQL
--> CSQL --> Databases
--> CSQL --> Backup
--> CSQL --> System
Example :
1
2
3
2
3
CSQL.Install()
-- you can also (its optional) pass multiple string arguments as database names.
CSQL.Install("DB1", "DB2")
createDatabase(string DB_NAME)create database folder in CSQL --> Databases -- > DB_NAME
Example :
1
CSQL.createDatabase("Mydb")
selectDatabase(string DB_NAME)select a database as active one.
Example :
1
CSQL.selectDatabase("Mydb")
createTable(TBL_NAME, COULMN_1, COULMN_2, COULMN_3, ....)create table file in CSQL --> Databases -- > ACTIVE_DB_NAME --> TBL_NAME.ctbl
Example :
1
CSQL.createTable("users", "name", "score", "level")
Query 
From(TABLE_NAME)
read all data from a table.
return a DATALIST(a 2D array include all rows in table).
data can't be used yet.
Example :
DATALIST.Where(first_value, operator, second_value)
restrict results by checking row by row if they pass through condition
return a DATALIST(a 2D array include all rows in table).
data can't be used yet.
Example :
also you can use where several times like this :
after limiting the results and reaching what you wanted using Where(), you can call (Select, Update, Delete)
DATALIST.Select() : to read results.
return array of rows.
its readable now.
Examples of Select :
Select, return an array can be used like this :
DATALIST.RowsNum : its a variable which contain number of rows in DATALIST.
for example if you want to check if a record exist or not you can :
DATALIST.GetFirst(Optional INDEX)
when you just want first result or there is just 1 result you can use :
DATALIST.LimitTo(TO) :you can limit number of result , for example i want 5 first result :
DATALIST.Update(COULMN, NEW_VALUE) : update coulmn COULMN by NEW_VALUE.
return DATALIST which means can be used cascading.
Examples of Update :
DATALIST.Delete() : to delete records.return true or false.
Examples of Delete :
CSQL.Query.Insert(TABLE_NAME, ...) : insert recors.return true or false.
1st argument is table name and others are coulmns value.
for example i have a table named 'users' with coulmn(name, score, level).
to insert value into it i must write something like this :
CSQL.attachPlayersTo(TABLE_NAME, USGNID) : you can attach a table to players list.
all data of table goes to a table(CSQL.Players[]).
when you write CSQL.Players[1]['coulmn_in_table'], it would return the coulmn value where usgnid == player 1's usgn.
if player 1 has no usng id , it would return false.
USGNID is coulmn name which containt users usgn id, by defualt its "usgnid" coulmn.

From(TABLE_NAME)read all data from a table.
return a DATALIST(a 2D array include all rows in table).
data can't be used yet.
Example :
1
CSQL.Query.From(TABLE_NAME)
DATALIST.Where(first_value, operator, second_value)restrict results by checking row by row if they pass through condition
return a DATALIST(a 2D array include all rows in table).
data can't be used yet.
Example :
1
2
3
4
5
6
2
3
4
5
6
CSQL.Query.From(TABLE_NAME).Where(VAL1, OPR, VAL2)
-- e.g :
-- it means return all rows which their score is more than 10
CSQL.Query.From(TABLE_NAME).Where("score", ">", "10")
-- it means return all rows which their level is admin
CSQL.Query.From(TABLE_NAME).Where("level", "==", "admin")
also you can use where several times like this :
1
2
3
4
2
3
4
CSQL.Query.From(TABLE_NAME).Where(VAL1, OPR, VAL2).Where(VAL3, OPR, VAL4).Where(VAL5, OPR, VAL6)
-- e.g :
-- it means return all rows which their mute is not 1 and level is admin
CSQL.Query.From(TABLE_NAME).Where("mute", "!=", "1").Where("level", "==", "admin")
after limiting the results and reaching what you wanted using Where(), you can call (Select, Update, Delete)
DATALIST.Select() : to read results.return array of rows.
its readable now.
Examples of Select :
1
2
3
4
2
3
4
-- reading all records
CSQL.Query.From("users").Select()
-- reading limited records
CSQL.Query.From("users").Where("level", ">", "10").Where("score", "<=", "200").Select()
1
2
3
4
5
2
3
4
5
-- reading limited records
Query = CSQL.Query.From("users").Where("score", ">=", "200").Select()
for key,row in ipairs(Query) do
	print(row['usgnid'])
end
DATALIST.RowsNum : its a variable which contain number of rows in DATALIST.for example if you want to check if a record exist or not you can :
1
2
3
4
2
3
4
usgnid = 12354
	if (CSQL.Query.From("users").Where("usgnid", "==", usgnid).RowsNum == 0) then
		CSQL.Query.Insert("users", usgnid, 0, 0)
	end
DATALIST.GetFirst(Optional INDEX)when you just want first result or there is just 1 result you can use :
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Row = CSQL.Query.From("users").Where("usngid", "==", "12345").GetFirst()
print(Row['steamid'])
print(Row['score'])
.
.
-- advance use of GetFirst :
CSQL.Query.From("users").Where("usngid", "==", "12345").GetFirst("hat")
-- or to convert string result to int
CSQL.Query.From("users").Where("usngid", "==", "12345").GetFirst("score"):toInt()
DATALIST.LimitTo(TO) :you can limit number of result , for example i want 5 first result :1
2
3
4
5
2
3
4
5
-- reading 5 first records
Query = CSQL.Query.From("users").Where("score", ">=", "200").LimitTo(5).Select()
for key,row in ipairs(Query) do
	print(row['usgnid'])
end
DATALIST.Update(COULMN, NEW_VALUE) : update coulmn COULMN by NEW_VALUE.return DATALIST which means can be used cascading.
Examples of Update :
1
2
2
-- update a player score and level
CSQL.Query.From("users").Where("usngid", "==", "12345").Update("score", sc+1).Update("level", lvl+1)
DATALIST.Delete() : to delete records.return true or false.Examples of Delete :
1
2
3
4
2
3
4
-- delete some records
CSQL.Query.From("users").Where("level", "!=", "admin").Delete()
-- delete all records
CSQL.Query.From("users").Delete()
CSQL.Query.Insert(TABLE_NAME, ...) : insert recors.return true or false.1st argument is table name and others are coulmns value.
for example i have a table named 'users' with coulmn(name, score, level).
to insert value into it i must write something like this :
1
CSQL.Query.Insert("users", "Jack", "250", "Vip")
CSQL.attachPlayersTo(TABLE_NAME, USGNID) : you can attach a table to players list.all data of table goes to a table(CSQL.Players[]).
when you write CSQL.Players[1]['coulmn_in_table'], it would return the coulmn value where usgnid == player 1's usgn.
if player 1 has no usng id , it would return false.
USGNID is coulmn name which containt users usgn id, by defualt its "usgnid" coulmn.
1
2
3
4
5
2
3
4
5
addhook("kill", "onKill")
function onKill(id)
	CSQL.attachPlayersTo("users", "usgnid")
	print("your score : ", CSQL.Players[id]['score'])
end
Example 

this is an example of CSQL usage system :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
-- Install CSQL
CSQL.Install("General")
CSQL.selectDatabase("General")
CSQL.createTable("Users", "usgnid", "score", "hat")
-- Querys
addhook("join", "onJoin")
function onJoin(id)
	if (player(id, "usgn") > 0) then
		if (CSQL.Query.From("Users").Where("usgnid", "==", player(id, "usgn")).RowsNum == 0) then
			CSQL.Query.Insert("Users", player(id, "usgn"), 0, 0)
		end
	end
end
addhook("kill", "onKill")
function onKill(id)
	if (player(id, "usgn") > 0) then
		CSQL.attachPlayersTo("Users")
		CSQL.Query.From("Users").Where("usgnid", "==", player(id, "usgn")).Update("score", CSQL.Players[id]["score"]:toInt()+1)
	end
end
addhook("say", "onSay")
function onSay(id, txt)
	if (player(id, "usgn") > 0) then
		if (txt == "!score") then
			Score = CSQL.Query.From("Users").Where("usgnid", "==", player(id, "usgn")).GetFirst("score")
			print(CSQL.Query.From("Users").Where("usgnid", "==", player(id, "usgn")).RowsNum, Score)
			msg("Score : " .. (Score))
		end
		if (txt == "!rs") then
			if (CSQL.Query.From("Users").Where("usgnid", "==", player(id, "usgn")).Delete()) then
				msg("Score Reseted !")
			end
		end
	end
end
edited 6×, last 02.05.18 03:57:57 pm
CSQL, new way in storing game data
1 
Offline
§2.2 - Only meaningful contributions with added value
_3yrus