Main ✸ Home Page ✸ Source Code ✸ Downloads ✸ API Documentation ✸ Mailing Lists ✸ Bugs ✸ Developers
Tcl example of database connection.
This will register the TCL procedure 'db_test' to requests for the dbtest.html page such that when a request is sent for dbtest.html then the procedure 'db_test' is run.
ns_register_proc GET /dbtest.html db_test proc db_test {} { set pool "main" set sql "select * from users" set db [ns_db gethandle $pool] set row [ns_db select $db $sql] set html "" while {[ns_db getrow $db $row]} { append html "<p>row: [ns_set array $row]</p>" } ns_db releasehandle $db ns_return 200 text/html $html }