Example of database connection using ns_db dml


MainHome Page Source Code Downloads API Documentation Mailing Lists Bugs Developers

ns_db dml

Tcl example of database connection using ns_db dml.

ns_register_proc GET /index.html db_test_dml

proc db_test_dml {} {
    set pool "main"
    set db [ns_db gethandle $pool]

    set sql "INSERT INTO users(user_id, firstname, surname, email)
             VALUES(1, 'Jane', 'Doe', '[email protected]')"
    ns_db dml $db $sql

    ns_db releasehandle $db


ns_db dml is normally used for INSERT, UPDATE and DELETE queries.