diff options
author | Benjamin Barenblat <bbaren@mit.edu> | 2013-04-21 17:06:35 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@mit.edu> | 2013-04-21 17:06:35 -0400 |
commit | 10698a19eeb4f6fbda18d601c0f8fd878734ab21 (patch) | |
tree | 779c4d1b21a9d9ae8844395882777773f2041dbc /forum/forum.ur | |
parent | 7d189e95615b37106d504415ce21b8eec8710080 (diff) |
Forum: Hook up to a database
Diffstat (limited to 'forum/forum.ur')
-rw-r--r-- | forum/forum.ur | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/forum/forum.ur b/forum/forum.ur index 8cb11da..6579e56 100644 --- a/forum/forum.ur +++ b/forum/forum.ur @@ -22,15 +22,31 @@ end) = struct open Styles +table question : { Id : int, + Body : string + } PRIMARY KEY Id +sequence questionIdS + fun main () : transaction page = + newestQuestions <- queryX (SELECT * FROM question) (fn row => + <xml> + <p>{[row.Question.Body]}</p> + </xml>); return ( Template.generic (Some "Forum") <xml> <div class={content}> - <p> - Coming soon! - </p> + <p>All questions:</p> + {newestQuestions} + <p>Ask a new question:</p> + <form><textbox {#Body} /><submit action={ask} value="Ask" /></form> </div> </xml> ) +and ask submission = + id <- nextval questionIdS; + dml (INSERT INTO question (Id, Body) + VALUES ({[id]}, {[submission.Body]})); + main () + end |