Commit | Line | Data |
---|---|---|
27e48ace AC |
1 | structure Pref :> PREF = |
2 | struct | |
3 | ||
4 | open Util Sql Init | |
5 | ||
6 | fun hasDirectory usr = | |
7 | case C.oneOrNoRows (getDb ()) ($`SELECT * FROM DirectoryPref WHERE usr = ^(C.intToSql usr)`) of | |
8 | NONE => false | |
9 | | _ => true | |
10 | ||
11 | fun setDirectory usr = | |
12 | if hasDirectory usr then | |
13 | () | |
14 | else | |
15 | ignore (C.dml (getDb ()) ($`INSERT INTO DirectoryPref (usr) VALUES (^(C.intToSql usr))`)) | |
16 | ||
17 | fun unsetDirectory usr = | |
18 | ignore (C.dml (getDb ()) ($`DELETE FROM DirectoryPref WHERE usr = ^(C.intToSql usr)`)) | |
19 | ||
20 | end |