annotate demo/sql.ur @ 1739:c414850f206f

Add support for -boot flag, which allows in-tree execution of Ur/Web The boot flag rewrites most hardcoded paths to point to the build directory, and also forces static compilation. This is convenient for developing Ur/Web, or if you cannot 'sudo make install' Ur/Web. The following changes were made: * Header files were moved to include/urweb instead of include; this lets FFI users point their C_INCLUDE_PATH at this directory at write <urweb/urweb.h>. For internal Ur/Web executables, we simply pass -I$PATH/include/urweb as normal. * Differentiate between LIB and SRCLIB; SRCLIB is Ur and JavaScript source files, while LIB is compiled products from libtool. For in-tree compilation these live in different places. * No longer reference Config for paths; instead use Settings; these settings can be changed dynamically by Compiler.enableBoot () (TODO: add a disableBoot function.) * config.h is now generated directly in include/urweb/config.h, for consistency's sake (especially since it gets installed along with the rest of the headers!) * All of the autotools build products got updated. * The linkStatic field in protocols now only contains the name of the build product, and not the absolute path. Future users have to be careful not to reference the Settings files to early, lest they get an old version (this was the source of two bugs during development of this patch.)
author Edward Z. Yang <ezyang@mit.edu>
date Wed, 02 May 2012 17:17:57 -0400
parents 5819fb63c93a
children
rev   line source
adamc@410 1 table t : { A : int, B : float, C : string, D : bool }
adamc@708 2 PRIMARY KEY A
adamc@410 3
adamc@410 4 fun list () =
adamc@410 5 rows <- queryX (SELECT * FROM t)
adamc@410 6 (fn row => <xml><tr>
adamc@410 7 <td>{[row.T.A]}</td> <td>{[row.T.B]}</td> <td>{[row.T.C]}</td> <td>{[row.T.D]}</td>
adamc@732 8 <td><form><submit action={delete row.T.A} value="Delete"/></form></td>
adamc@410 9 </tr></xml>);
adamc@410 10 return <xml>
adamc@410 11 <table border=1>
adamc@410 12 <tr> <th>A</th> <th>B</th> <th>C</th> <th>D</th> </tr>
adamc@410 13 {rows}
adamc@410 14 </table>
adamc@410 15
adamc@410 16 <br/><hr/><br/>
adamc@410 17
adamc@410 18 <form>
adamc@410 19 <table>
adamc@410 20 <tr> <th>A:</th> <td><textbox{#A}/></td> </tr>
adamc@410 21 <tr> <th>B:</th> <td><textbox{#B}/></td> </tr>
adamc@410 22 <tr> <th>C:</th> <td><textbox{#C}/></td> </tr>
adamc@410 23 <tr> <th>D:</th> <td><checkbox{#D}/></td> </tr>
adamc@410 24 <tr> <th/> <td><submit action={add} value="Add Row"/></td> </tr>
adamc@410 25 </table>
adamc@410 26 </form>
adamc@410 27 </xml>
adamc@410 28
adamc@410 29 and add r =
adamc@434 30 dml (INSERT INTO t (A, B, C, D)
adamc@471 31 VALUES ({[readError r.A]}, {[readError r.B]}, {[r.C]}, {[r.D]}));
adamc@410 32 xml <- list ();
adamc@410 33 return <xml><body>
adamc@410 34 <p>Row added.</p>
adamc@410 35
adamc@410 36 {xml}
adamc@410 37 </body></xml>
adamc@410 38
adamc@732 39 and delete a () =
adamc@434 40 dml (DELETE FROM t
adamc@471 41 WHERE t.A = {[a]});
adamc@410 42 xml <- list ();
adamc@410 43 return <xml><body>
adamc@410 44 <p>Row deleted.</p>
adamc@410 45
adamc@410 46 {xml}
adamc@410 47 </body></xml>
adamc@410 48
adamc@410 49 fun main () =
adamc@410 50 xml <- list ();
adamc@410 51 return <xml><body>
adamc@410 52 {xml}
adamc@410 53 </body></xml>