cson  Update of "cson_cpdo"

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: 653bce655ed909d00ff83e6e1cadd23978f70a29
Page Name:cson_cpdo
Date: 2011-05-09 17:58:44
Original User: stephan
Parent: 26feb3b1612cf3420ade42a6c7e189b6cf49e59e
Content

ACHTUNG: THIS PAGE IS NOW MAINTAINED IN THE NEW WIKI: http://whiki.wanderinghorse.net/wikis/cson/?page=cson_cpdo

See also: cson_sqlite3, select-to-json

cson_cpdo

The cson_cpdo family of functions, declared in cson_cpdo.h, mostly work identically to the cson_sqlite3 family of functions except that they use cpdo database connections instead of sqlite3 connections. See cson_sqlite3 for the details and examples of the generated JSON structure. In addition, the cson_cpdo API has convenience routines for binding JSON values to db columns, parsing those values, and converting individual db SELECT rows to objects or arrays of JSON values.

The macro CPDO_ENABLE_CPDO must be set to a true value when this code (or the amalgamation build) is compiled, or else these functions will not be included.

When using this code from client applications, they may need to do the following from somewhere near the start of the application to register the specific database drivers:

// The following functions are exposed via either the cpdo headers or
// the cson amalgamation, depending on how the build is constructed.
#if CPDO_ENABLE_SQLITE3
    cpdo_driver_sqlite3_register();
#endif
#if CPDO_ENABLE_MYSQL5
    cpdo_driver_mysql5_register();
#endif

Without those registrations, cpdo won't be able to connect to the given database type.

When using cson_cgi with sessions support, this CGI initialization process does this for the client only if sessions are configured to use cpdo for the back-end and the cson_session bits were compiled with the proper flags to enable each database driver (see AmalgamationBuild for those flags).

See the cpdo wiki for more details about compiling specific driver support into cpdo.