Talk:Accessing A Database
Revision as of 20:02, 1 December 2005 by 129.33.49.251 (talk)
the examples are malformed, the brackets [ ] are estranged or omitted. in other words, cut and paste produces non-working code. possible suggestions are using the "<nowiki>" or "pre" tags, but i dislike this as an overall solution because linking ns_db to ns_db could be useful and the nowiki or pre tag would remove that. isn't there a simple way to insert a bracket character? or would we need to use the entity code with &code for brackets? that would make pasting code into the wiki very hard.
suggestion, use "pre" for now and not worry about wiki linking from code examples:
<%
# change "poolname" to match the pool you defined in your config.tcl
set pool "poolname"
# change to reflect the SQL you wish to execute
set sql "SELECT NOW()"
set db ""
catch {
set db [ns_db gethandle $pool]
set row [ns_db select $db $sql]
while {[ns_db getrow $db $row]} {
ns_adp_puts "row: [ns_set array $row]"
}
}
catch { ns_db releasehandle $db }
%>