db_types.anubis
1.52 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Created by PyramIDE.
* User: Totoro
* Date: 14/11/2011
* Time: 22:41
*
*/
transmit tools/basis.anubis
public type DB_id:
none,
db_id(Int value).
public type DB_datetime:
db_datetime(String datetime). //Date and time in ISO8601 format "YYYY-MM-DD hh:mm:ss"
public type DB_date:
db_date(String date). //Date in ISO8601 format "YYYY-MM-DD"
public type DB_time:
db_time(String time). //Time in ISO8601 format "hh:mm:ss"
public type DB_integer:
db_integer(Int value).
public define String
to_String
(
DB_id idx
)=
if idx is
{
none then "none",
db_id(idx) then abs_to_decimal(idx)
}.
public define String
to_String
(
DB_date d
)=
date(d).
public define String
to_String
(
DB_datetime dt
)=
datetime(dt).
public define String
to_String
(
DB_time t
)=
time(t).
public define String
to_DBString
(
Bool value
)=
if value then "1" else "0".
public define Int
to_DBInt
(
Bool value
)=
if value then 1 else 0.
public type SQLite3_update_field:
field(String column, SQLite3Bind bind).
* Some Bind helper *
/********** Some default type values ********************/
public define Maybe(DB_datetime)
get_dummy_DB_datetime
=
success(db_datetime("")).
public define DB_datetime
now
=
_Int_to_ISO_8601_datetime(now).
public define Maybe(DB_time)
get_dummy_DB_time
=
success(db_time("")).
public define Maybe(DB_date)
get_dummy_DB_date
=
success(db_date("")).