-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.cfm
31 lines (26 loc) · 1.47 KB
/
demo.cfm
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
<cfscript>
dsn = "cfartgallery";
db = createObject("component","dbservice").init( dsn );
i = 0;
//writeDump(db.select( table='artists', where={'FAX is'=''} ));
show("Get all the artists","db.select('artists');");
show("Artists in California and New York","db.select( table='artists', where={'state in' = 'CA,NY'} );");
show("Get artists with last name starting with 'T'","db.select( table='artists', where={'lastname LIKE' = 'T%'} );");
show("Get Orders with status between 1 and 3","db.select( table='orders', where={'orderstatusid BETWEEN'='1 AND 3'} );");
show("Filter artists where FAX is NULL","db.select( table='artists', where={'FAX is'=''} );");
show("Insert a new artist","newid = db.insert(table='artists',firstName='Jizanthapus',lastName='Szekely');");
show("Get the new artist","db.selectRow('artists',newid);");
show("Delete the new artist","db.deleteRow('artists',newid);");
</cfscript>
<cfscript>
//this is not material to the demo -- just a convenient way to spit out code to the screen and execute it without typing it twice
function show(title,code){
writeOutput("<h2>" & arguments.title & "</h2>");
writeOutput("<h3>" & htmlCodeFormat(code) & "<h3>");
fileWrite(expandPath("temp#++i#.cfm"),"<cfscript> function tempcode#i#(){var r = " & code & " if(isDefined('r')) return r;} </cfscript>");
include "temp#i#.cfm";
writeDump(evaluate("tempCode#i#()"));
fileDelete(expandPath("temp#i#.cfm"));
writeOutput("<hr>");
}
</cfscript>