Talk:Accessing A Database
Jump to navigation
Jump to search
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)