Difference between revisions of "Talk:Accessing A Database"
Jump to navigation
Jump to search
| (One intermediate revision by one other user not shown) | |||
| 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> | ||
| + | |||
| + | * A single bracket is a literal bracket except when surrounding a URL. Double brackets link to internal page names. I'll go fix the examples to render properly in MediaWiki. Thanks for bringing it up. ''-- [[User:Dossy|Dossy]] 19:35, 1 December 2005 (EST)'' | ||
Latest revision as of 00:35, 2 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 }
%>
- A single bracket is a literal bracket except when surrounding a URL. Double brackets link to internal page names. I'll go fix the examples to render properly in MediaWiki. Thanks for bringing it up. -- Dossy 19:35, 1 December 2005 (EST)