Index: openacs-4/packages/acs-core-docs/www/db-api-detailed.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/db-api-detailed.html,v diff -u -r1.31.2.4 -r1.31.2.5 --- openacs-4/packages/acs-core-docs/www/db-api-detailed.html 22 Oct 2004 02:38:14 -0000 1.31.2.4 +++ openacs-4/packages/acs-core-docs/www/db-api-detailed.html 1 Nov 2004 23:39:37 -0000 1.31.2.5 @@ -1,7 +1,7 @@ -Database Access API

Database Access API

By Jon Salz. Revised and expanded by Roberto Mello (rmello at fslc dot usu dot edu), July 2002.

+Database Access API

Database Access API

By Jon Salz. Revised and expanded by Roberto Mello (rmello at fslc dot usu dot edu), July 2002.

OpenACS docs are written by the named authors, and may be edited by OpenACS documentation staff. -
  • Tcl procedures: /packages/acs-kernel/10-database-procs.tcl

  • Tcl initialization: /packages/acs-kernel/database-init.tcl

The Big Picture

+

  • Tcl procedures: /packages/acs-kernel/10-database-procs.tcl

  • Tcl initialization: /packages/acs-kernel/database-init.tcl

The Big Picture

One of OpenACS's great strengths is that code written for it is very close to the database. It is very easy to interact with the database from anywhere within OpenACS. Our goal is to develop a coherent API for database access which @@ -77,7 +77,7 @@ design. Therefore, we know that the effort will not be wasted, and taking advantage of the new support for bind variables will already require code that uses 3.3.0 version of the API to be updated. -

The Bell Tolls for set_variables_after_query

+

The Bell Tolls for set_variables_after_query

set_variables_after_query is gone! (Well, it's still there, but you'll never need to use it.) The new API routines set local variables automatically. For instance: @@ -122,7 +122,7 @@ doc_body_append "There aren't any users with last names beginnings with S!" } -

Handle Management

+

Handle Management

The new API keeps track of which handles are in use, and automatically allocates new handles when they are necessary (e.g., to perform subqueries while a select is active). For example: @@ -151,7 +151,7 @@ until db_release_unused_handles is invoked (or the script terminates).

Note that there is no analogue to ns_db gethandle - the -handle is always automatically allocated the first time it's needed.

Bind Variables

Introduction

+handle is always automatically allocated the first time it's needed.

Bind Variables

Introduction

Most SQL statements require that the code invoking the statement pass along data associated with that statement, usually obtained from the user. For instance, in order to delete a WimpyPoint presentation, a Tcl script might @@ -336,13 +336,13 @@ # # sets the values for both the "bar" and "baz" columns to null -

SQL Abstraction

+

SQL Abstraction

We now require that each SQL statement be assigned a logical name for the statement that is unique to the procedure or page in which it is defined. This is so that (eventually) we can implement logically named statements with alternative SQL for non-Oracle databases (e.g., Postgres). More on this later. -

Placing Column Values in Arrays and Sets

+

Placing Column Values in Arrays and Sets

Normally, db_foreach, db_0or1row, and db_1row places the results of queries in Tcl variables, so you can say: @@ -373,7 +373,7 @@

will write something like: -

  • first_names is Jon. last_name is Salz.

  • first_names is Lars. last_name is Pind.

  • first_names is Michael. last_name is Yoon.

API

+

  • first_names is Jon. last_name is Salz.

  • first_names is Lars. last_name is Pind.

  • first_names is Michael. last_name is Yoon.

API

Note that you never have to use ns_db anymore (including ns_db gethandle)! Just start doing stuff, and (if you want) call db_release_unused_handles when you're done as a hint to