db_driverkey (public)

 db_driverkey [ -handle_p handle_p ] dbn

Defined in packages/acs-tcl/tcl/01-database-procs.tcl

Normally, a dbn is passed to this proc. Unfortunately, there are one or two cases where a proc that needs to call this one has only a db handle, not the dbn that handle came from. Therefore, they instead use -handle_p 1 and pass the db handle. Hmm, as of 2018, it seems that in most cases, db_driverkey is called with a handle.

Switches:
-handle_p (optional, defaults to "0")
Parameters:
dbn (required)
Returns:
The driverkey for use in db_* API switch statements.
Author:
Andrew Piskorski <atp@piskorski.com>
Created:
2003/04/08

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_form_with_form_instance create_form_with_form_instance (test xowiki) db_driverkey db_driverkey test_create_form_with_form_instance->db_driverkey db_with_handle db_with_handle (public) db_driverkey->db_with_handle acs::db::require_dc acs::db::require_dc (private) acs::db::require_dc->db_driverkey ad_acs_require_basic_schemata ad_acs_require_basic_schemata (private) ad_acs_require_basic_schemata->db_driverkey ad_set_client_property ad_set_client_property (public) ad_set_client_property->db_driverkey category::list::rewrite_query category::list::rewrite_query (public) category::list::rewrite_query->db_driverkey content::revision::new content::revision::new (public) content::revision::new->db_driverkey

Testcases:
create_form_with_form_instance
Source code:
    if { $handle_p } {
        #
        # Input is a handle, not a database name. Determine from the
        # handle the db-name (via the pool information)
        #
        set handle $dbn
        set pool [ns_db poolname $handle]
        set dbn $::acs::db_pool_to_dbn($pool)
    }

    if { ![nsv_get db_driverkey $dbn driverkey] } {
        #
        # This ASSUMES that any overriding of this default value via
        # "ns_param driverkey_dbn" has already been done:
        #
        if { $handle_p } {
            set driver [ns_db driver $handle]
        } else {
            db_with_handle -dbn $dbn handle {
                set driver [ns_db driver $handle]
            }
        }

        # These are the default driverkey values, if they are not set
        # in the config file:

        if { [string match "Oracle*" $driver] } {
            set driverkey {oracle}
        } elseif$driver eq "PostgreSQL" } {
            set driverkey "postgresql"
        } elseif$driver eq "ODBC" } {
            set driverkey "nsodbc"
        } else {
            set driverkey {}
            ns_log Error "db_driverkey: Unknown driver '$driver'."
        }

        nsv_set db_driverkey $dbn $driverkey
    }
    return $driverkey
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: