Docs GODI Archive
Projects Blog Knowledge

Look up function:

(e.g. "List.find" or "keysym")
More options

Module type Netcgi_dbi.DBI_POOL


module type DBI_POOL = sig .. end

type connection 
val get : Netcgi.cgi ->
?host:string ->
?port:string ->
?user:string -> ?password:string -> string -> connection
Example: module MyPool = DbiPool(Dbi_postgres)

let dbh = MyPool.get request "database_name"

Returns an unused Dbi.connection handle from the pool of database handles. Or it may create a new database connection and return that.

The parameters uniquely identify the database name (eg. "comments") and optional parameters. Separate pools are maintained for each combination of parameters.

The connection is automatically returned to the pool at the end of the cgi request. After this time the connection may be given away to another user. For this reason, the calling code must NEVER stash the connection across requests (instead, call get to get a new handle each time).

On returning the handle to the pool, the pool performs a ROLLBACK operation on the handle, thus losing any changes (INSERT, etc.) made to the database. If the program wants to preserve changes, it must perform a COMMIT operation itself, by calling Dbi.connection.commit.

This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml