· 7 years ago · Nov 27, 2018, 12:08 AM
1script options:
2 $ db url jdbc:mysql://IP:3306/DATABASE
3 $ db username USER
4 $ db password PASSWORD
5
6options:
7 Table: TABLENAME
8
9
10on load:
11 update "CREATE TABLE IF NOT EXISTS `{@Table}` (`id` varchar(255),`value` varchar(255))"
12 update "ALTER TABLE {@Table} ADD UNIQUE (id, value)"
13
14function thisMySQLUpdatevalue(id:text, value:text) :: text:
15 set {_SetResult::*} to objects in column "id" from result of query "SELECT * FROM {@Table} WHERE id = '%{_id}%'" and close
16 set {_GetResult} to false
17 loop {_SetResult::*}:
18 If loop-value is {_id}:
19 set {_GetResult} to true
20 If {_GetResult} is false:
21 update "INSERT INTO `{@Table}` (`id`,`value`) valueS ('%{_id}%', '%{_value}%')"
22 return "&e%{_id}% &ahas been succesfully &5&lCREATED &awith value &e%{_value}% &ain table &b{@Table}"
23 else:
24 update "UPDATE `{@Table}` SET `value` = '%{_value}%' WHERE `{@Table}`.`id` ='%{_id}%'"
25 return "&e%{_id}% &ahas been succesfully &5&lUPDATED &awith value &e%{_value}% &ain table &b{@Table}"
26
27function thisMySQLRemovevalue(id:text) :: text:
28 set {_SetResult::*} to objects in column "id" from result of query "SELECT * FROM {@Table} WHERE id = '%{_id}%'" and close
29 set {_GetResult} to false
30 loop {_SetResult::*}:
31 If loop-value is {_id}:
32 set {_GetResult} to true
33 If {_GetResult} is true:
34 update "DELETE FROM {@Table} WHERE id = '%{_id}%'"
35 return "&e%{_id}% &ahas been succesfully &5&lDELETED &afrom table &b{@Table}"
36 else:
37 return "&cid &e%{_id}% &ccouldn't be found in table &b{@Table}"
38
39function thisMySQLReadvalue(id:text) :: text:
40 set {_SetResult::*} to objects in column "value" from result of query "SELECT * FROM {@Table} WHERE id = '%{_id}%'" and close
41 delete {_GetResult}
42 loop {_SetResult::*}:
43 If loop-value is set:
44 set {_GetResult} to loop-value
45 If {_GetResult} is set:
46 return "&aThe value of &b%{_id}% &ais &b%{_GetResult}% &ain table &b{@Table}"
47 else:
48 return "&cid &e%{_id}% &ccouldn't be found in table &b{@Table}"