11 --Keyword -> (Full text,date)
12 getCurrent :: a -> String -> IO (String,String)
14 --Keyword -> [(id,date)]
15 getList :: a -> String -> IO [(String, String, String, String)]
17 --Keyword -> id -> Full text
18 get :: a -> String -> String -> IO String
21 setCurrent :: a -> String -> String -> IO Int
23 --Keyword -> Full text -> id
24 addNew :: a -> String -> String -> IO String
26 data PGB = PGB DBService
28 createPGB :: String -> String -> String -> String -> IO PGB
29 createPGB host database user password = let db = createDBService host database "" user password Nothing in return (PGB db)
32 testDB = createPGB "wave" "wiki" "wiki" "12wiki34db"
36 getCurrent (PGB db) key = do
37 [[text,date]] <- selectReturnTuples db $ "SELECT fulltext,timestamp FROM curtexts where keyword='"++(escapeQuery key)++"'"
40 getList (PGB db) key = do
41 list <- selectReturnTuples db $ "SELECT id, timestamp, author, comment from fulltexts where keyword = '"++(escapeQuery key)++"'"
42 return $ map (\[id,date,author,comment] -> (id,date,author,comment)) list
44 get (PGB db) key id = return ""
46 setCurrent (PGB db) key id =
47 execute db $ "UPDATE current SET id = '"++(escapeQuery id)++"' where keyword = '"++(escapeQuery key)++"'"
49 addNew (PGB db) key text = return ""