|
@@ -14,8 +14,8 @@
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
* GNU General Public License for more details.
|
|
*
|
|
*
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
|
- * along with this program; if not, write to the Free Software
|
|
|
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
|
+ * along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -53,7 +53,7 @@
|
|
|
|
|
|
/**
|
|
/**
|
|
* \brief Specify table name that will be used for subsequent operations.
|
|
* \brief Specify table name that will be used for subsequent operations.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* The function db_use_table takes a table name and stores it db1_con_t structure.
|
|
* The function db_use_table takes a table name and stores it db1_con_t structure.
|
|
* All subsequent operations (insert, delete, update, query) are performed on
|
|
* All subsequent operations (insert, delete, update, query) are performed on
|
|
* that table.
|
|
* that table.
|
|
@@ -69,11 +69,11 @@ typedef int (*db_use_table_f)(db1_con_t* _h, const str * _t);
|
|
* This function initializes the database API and opens a new database
|
|
* This function initializes the database API and opens a new database
|
|
* connection. This function must be called after bind_dbmod but before any
|
|
* connection. This function must be called after bind_dbmod but before any
|
|
* other database API function is called.
|
|
* other database API function is called.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* The function takes one parameter, the parameter must contain the database
|
|
* The function takes one parameter, the parameter must contain the database
|
|
- * connection URL. The URL is of the form
|
|
|
|
|
|
+ * connection URL. The URL is of the form
|
|
* mysql://username:password\@host:port/database where:
|
|
* mysql://username:password\@host:port/database where:
|
|
- *
|
|
|
|
|
|
+ *
|
|
* username: Username to use when logging into database (optional).
|
|
* username: Username to use when logging into database (optional).
|
|
* password: password if it was set (optional)
|
|
* password: password if it was set (optional)
|
|
* host: Hosname or IP address of the host where database server lives (mandatory)
|
|
* host: Hosname or IP address of the host where database server lives (mandatory)
|
|
@@ -93,11 +93,11 @@ typedef db1_con_t* (*db_init_f) (const str* _sqlurl);
|
|
* This function initializes the database API and opens a new database
|
|
* This function initializes the database API and opens a new database
|
|
* connection. This function must be called after bind_dbmod but before any
|
|
* connection. This function must be called after bind_dbmod but before any
|
|
* other database API function is called.
|
|
* other database API function is called.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* The function takes one parameter, the parameter must contain the database
|
|
* The function takes one parameter, the parameter must contain the database
|
|
- * connection URL. The URL is of the form
|
|
|
|
|
|
+ * connection URL. The URL is of the form
|
|
* mysql://username:password\@host:port/database where:
|
|
* mysql://username:password\@host:port/database where:
|
|
- *
|
|
|
|
|
|
+ *
|
|
* username: Username to use when logging into database (optional).
|
|
* username: Username to use when logging into database (optional).
|
|
* password: password if it was set (optional)
|
|
* password: password if it was set (optional)
|
|
* host: Hosname or IP address of the host where database server lives (mandatory)
|
|
* host: Hosname or IP address of the host where database server lives (mandatory)
|
|
@@ -115,11 +115,11 @@ typedef db1_con_t* (*db_init2_f) (const str* _sqlurl, db_pooling_t _pooling);
|
|
/**
|
|
/**
|
|
* \brief Close a database connection and free all memory used.
|
|
* \brief Close a database connection and free all memory used.
|
|
*
|
|
*
|
|
- * The function closes previously open connection and frees all previously
|
|
|
|
|
|
+ * The function closes previously open connection and frees all previously
|
|
* allocated memory. The function db_close must be the very last function called.
|
|
* allocated memory. The function db_close must be the very last function called.
|
|
* \param _h db1_con_t structure representing the database connection
|
|
* \param _h db1_con_t structure representing the database connection
|
|
*/
|
|
*/
|
|
-typedef void (*db_close_f) (db1_con_t* _h);
|
|
|
|
|
|
+typedef void (*db_close_f) (db1_con_t* _h);
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -223,11 +223,11 @@ typedef int (*db_free_result_f) (db1_con_t* _h, db1_res_t* _r);
|
|
|
|
|
|
/**
|
|
/**
|
|
* \brief Insert a row into the specified table.
|
|
* \brief Insert a row into the specified table.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* This function implements INSERT SQL directive, you can insert one or more
|
|
* This function implements INSERT SQL directive, you can insert one or more
|
|
* rows in a table using this function.
|
|
* rows in a table using this function.
|
|
* \param _h database connection handle
|
|
* \param _h database connection handle
|
|
- * \param _k array of keys (column names)
|
|
|
|
|
|
+ * \param _k array of keys (column names)
|
|
* \param _v array of values for keys specified in _k parameter
|
|
* \param _v array of values for keys specified in _k parameter
|
|
* \param _n number of keys-value pairs int _k and _v parameters
|
|
* \param _n number of keys-value pairs int _k and _v parameters
|
|
* \return returns 0 if everything is OK, otherwise returns value < 0
|
|
* \return returns 0 if everything is OK, otherwise returns value < 0
|
|
@@ -244,7 +244,7 @@ typedef int (*db_insert_f) (const db1_con_t* _h, const db_key_t* _k,
|
|
* If _k is NULL and _v is NULL and _n is zero, all rows are deleted, the
|
|
* If _k is NULL and _v is NULL and _n is zero, all rows are deleted, the
|
|
* resulting table will be empty.
|
|
* resulting table will be empty.
|
|
* If _o is NULL, the equal operator "=" will be used for the comparison.
|
|
* If _o is NULL, the equal operator "=" will be used for the comparison.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* \param _h database connection handle
|
|
* \param _h database connection handle
|
|
* \param _k array of keys (column names) that will be matched
|
|
* \param _k array of keys (column names) that will be matched
|
|
* \param _o array of operators to be used with key-value pairs
|
|
* \param _o array of operators to be used with key-value pairs
|
|
@@ -301,7 +301,7 @@ typedef int (*db_replace_f) (const db1_con_t* handle, const db_key_t* keys,
|
|
* \brief Retrieve the last inserted ID in a table.
|
|
* \brief Retrieve the last inserted ID in a table.
|
|
*
|
|
*
|
|
* The function returns the value generated for an AUTO_INCREMENT column by the
|
|
* The function returns the value generated for an AUTO_INCREMENT column by the
|
|
- * previous INSERT or UPDATE statement. Use this function after you have
|
|
|
|
|
|
+ * previous INSERT or UPDATE statement. Use this function after you have
|
|
* performed an INSERT statement into a table that contains an AUTO_INCREMENT
|
|
* performed an INSERT statement into a table that contains an AUTO_INCREMENT
|
|
* field.
|
|
* field.
|
|
* \param _h structure representing database connection
|
|
* \param _h structure representing database connection
|
|
@@ -313,7 +313,7 @@ typedef int (*db_last_inserted_id_f) (const db1_con_t* _h);
|
|
|
|
|
|
/**
|
|
/**
|
|
* \brief Insert a row into specified table, update on duplicate key.
|
|
* \brief Insert a row into specified table, update on duplicate key.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* The function implements the INSERT ON DUPLICATE KEY UPDATE SQL directive.
|
|
* The function implements the INSERT ON DUPLICATE KEY UPDATE SQL directive.
|
|
* It is possible to insert a row and update if one already exists.
|
|
* It is possible to insert a row and update if one already exists.
|
|
* The old row will not deleted before the insertion of the new data.
|
|
* The old row will not deleted before the insertion of the new data.
|
|
@@ -368,7 +368,7 @@ typedef int (*db_insert_async_f) (const db1_con_t* _h, const db_key_t* _k,
|
|
typedef int (*db_affected_rows_f) (const db1_con_t* _h);
|
|
typedef int (*db_affected_rows_f) (const db1_con_t* _h);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * \brief Start a single transaction that will consist of one or more queries.
|
|
|
|
|
|
+ * \brief Start a single transaction that will consist of one or more queries.
|
|
*
|
|
*
|
|
* \param _h structure representing database connection
|
|
* \param _h structure representing database connection
|
|
* \return 0 if everything is OK, otherwise returns < 0
|
|
* \return 0 if everything is OK, otherwise returns < 0
|
|
@@ -376,7 +376,7 @@ typedef int (*db_affected_rows_f) (const db1_con_t* _h);
|
|
typedef int (*db_start_transaction_f) (db1_con_t* _h, db_locking_t _l);
|
|
typedef int (*db_start_transaction_f) (db1_con_t* _h, db_locking_t _l);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * \brief End a transaction.
|
|
|
|
|
|
+ * \brief End a transaction.
|
|
*
|
|
*
|
|
* \param _h structure representing database connection
|
|
* \param _h structure representing database connection
|
|
* \return 0 if everything is OK, otherwise returns < 0
|
|
* \return 0 if everything is OK, otherwise returns < 0
|
|
@@ -395,7 +395,7 @@ typedef int (*db_abort_transaction_f) (db1_con_t* _h);
|
|
|
|
|
|
/**
|
|
/**
|
|
* \brief Database module callbacks
|
|
* \brief Database module callbacks
|
|
- *
|
|
|
|
|
|
+ *
|
|
* This structure holds function pointer to all database functions. Before this
|
|
* This structure holds function pointer to all database functions. Before this
|
|
* structure can be used it must be initialized with bind_dbmod.
|
|
* structure can be used it must be initialized with bind_dbmod.
|
|
* \see bind_dbmod
|
|
* \see bind_dbmod
|
|
@@ -411,12 +411,12 @@ typedef struct db_func {
|
|
db_raw_query_f raw_query; /* Raw query - SQL */
|
|
db_raw_query_f raw_query; /* Raw query - SQL */
|
|
db_free_result_f free_result; /* Free a query result */
|
|
db_free_result_f free_result; /* Free a query result */
|
|
db_insert_f insert; /* Insert into table */
|
|
db_insert_f insert; /* Insert into table */
|
|
- db_delete_f delete; /* Delete from table */
|
|
|
|
|
|
+ db_delete_f delete; /* Delete from table */
|
|
db_update_f update; /* Update table */
|
|
db_update_f update; /* Update table */
|
|
db_replace_f replace; /* Replace row in a table */
|
|
db_replace_f replace; /* Replace row in a table */
|
|
db_last_inserted_id_f last_inserted_id; /* Retrieve the last inserted ID
|
|
db_last_inserted_id_f last_inserted_id; /* Retrieve the last inserted ID
|
|
in a table */
|
|
in a table */
|
|
- db_insert_update_f insert_update; /* Insert into table, update on duplicate key */
|
|
|
|
|
|
+ db_insert_update_f insert_update; /* Insert into table, update on duplicate key */
|
|
db_insert_delayed_f insert_delayed; /* Insert delayed into table */
|
|
db_insert_delayed_f insert_delayed; /* Insert delayed into table */
|
|
db_insert_async_f insert_async; /* Insert async into table */
|
|
db_insert_async_f insert_async; /* Insert async into table */
|
|
db_affected_rows_f affected_rows; /* Number of affected rows for last query */
|
|
db_affected_rows_f affected_rows; /* Number of affected rows for last query */
|
|
@@ -432,7 +432,7 @@ typedef struct db_func {
|
|
* \brief Bind database module functions
|
|
* \brief Bind database module functions
|
|
*
|
|
*
|
|
* This function is special, it's only purpose is to call find_export function in
|
|
* This function is special, it's only purpose is to call find_export function in
|
|
- * the core and find the addresses of all other database related functions. The
|
|
|
|
|
|
+ * the core and find the addresses of all other database related functions. The
|
|
* db_func_t callback given as parameter is updated with the found addresses.
|
|
* db_func_t callback given as parameter is updated with the found addresses.
|
|
*
|
|
*
|
|
* This function must be called before any other database API call!
|
|
* This function must be called before any other database API call!
|
|
@@ -479,7 +479,7 @@ db1_con_t* db_do_init2(const str* url, void* (*new_connection)(), db_pooling_t p
|
|
/**
|
|
/**
|
|
* \brief Helper for db_close function.
|
|
* \brief Helper for db_close function.
|
|
*
|
|
*
|
|
- * This helper method does some work for the closing of a database
|
|
|
|
|
|
+ * This helper method does some work for the closing of a database
|
|
* connection. No function should be called after this
|
|
* connection. No function should be called after this
|
|
* \param _h database connection handle
|
|
* \param _h database connection handle
|
|
* \param (*free_connection) Pointer to the db specific free_connection method
|
|
* \param (*free_connection) Pointer to the db specific free_connection method
|