cson  Artifact Content

Artifact 653bce655ed909d00ff83e6e1cadd23978f70a29:

Wiki page [cson_cpdo] by stephan 2011-05-09 17:58:44.
D 2011-05-09T17:58:44.549
L cson_cpdo
P 26feb3b1612cf3420ade42a6c7e189b6cf49e59e
U stephan
W 2059
<strong>ACHTUNG: THIS PAGE IS NOW MAINTAINED IN THE NEW WIKI:</strong> [http://whiki.wanderinghorse.net/wikis/cson/?page=cson_cpdo]

See also: [cson_sqlite3], [select-to-json]


The <tt>cson_cpdo</tt> family of functions, declared in <tt>[/finfo?name=include/wh/cson/cson_cpdo.h|cson_cpdo.h]</tt>, mostly work identically to the [cson_sqlite3] family of functions except that they use [http://fossil.wanderinghorse.net/repos/cpdo/|cpdo] database connections instead of sqlite3 connections. See [cson_sqlite3] for the details and examples of the generated JSON structure. In addition, the <tt>cson_cpdo</tt> API has convenience routines for binding JSON values to db columns, parsing those values, and converting individual db <tt>SELECT</tt> rows to objects or arrays of JSON values.

The macro <tt>CPDO_ENABLE_CPDO</tt> must be set to a true value when this code (or the [AmalgamationBuild|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.

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 <em>only if</em> sessions are configured to use cpdo for the back-end <em>and</em> the [cson_session] bits were compiled with the proper flags to enable each database driver (see [AmalgamationBuild] for those flags).

See [http://fossil.wanderinghorse.net/repos/cpdo/index.cgi/wiki/AmalgamationBuild|the cpdo wiki] for more details about compiling specific driver support into cpdo.

Z 873e324a1de063081867a586a128bd92