Difference between revisions of "Talk:Accessing A Database"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
− | the examples are malformed, the brackets <nowiki>[ ]</nowiki> are estranged or omitted. in other words, cut and paste produces non-working code. | + | the examples are malformed, the brackets <nowiki>[ ]</nowiki> 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: | ||
+ | |||
+ | <pre> | ||
+ | <% | ||
+ | # 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 } | ||
+ | %> | ||
+ | </pre> |
Revision as of 20:02, 1 December 2005
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 } %>