ACHTUNG: THIS PAGE IS NOW MAINTAINED IN THE NEW WIKI: http://whiki.wanderinghorse.net/wikis/cson/?page=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.