Module: DB_MYSQL :: the MySQL driver for Kamailio. More...
#include "../../db/db_con.h"
#include "../../db/db_res.h"
#include "../../db/db_key.h"
#include "../../db/db_op.h"
#include "../../db/db_val.h"
#include "../../str.h"


Go to the source code of this file.
Functions | |
| int | db_insert_update (const db_con_t *_h, const db_key_t *_k, const db_val_t *_v, const int _n) |
| Insert a row into table, update on duplicate key. | |
| int | db_last_inserted_id (const db_con_t *_h) |
| Returns the last inserted ID. | |
| void | db_mysql_close (db_con_t *_h) |
| Close a database connection. | |
| int | db_mysql_delete (const db_con_t *_h, const db_key_t *_k, const db_op_t *_o, const db_val_t *_v, const int _n) |
| Delete a row from table. | |
| int | db_mysql_fetch_result (const db_con_t *_h, db_res_t **_r, const int nrows) |
| fetch rows from a result | |
| int | db_mysql_free_result (db_con_t *_h, db_res_t *_r) |
| Free all memory allocated by get_result. | |
| db_con_t * | db_mysql_init (const str *_sqlurl) |
| Initialize database connection. | |
| int | db_mysql_insert (const db_con_t *_h, const db_key_t *_k, const db_val_t *_v, const int _n) |
| Insert a row into table. | |
| int | db_mysql_query (const db_con_t *_h, const db_key_t *_k, const db_op_t *_op, const db_val_t *_v, const db_key_t *_c, const int _n, const int _nc, const db_key_t _o, db_res_t **_r) |
| Do a query. | |
| int | db_mysql_raw_query (const db_con_t *_h, const str *_s, db_res_t **_r) |
| Raw SQL query. | |
| int | db_mysql_replace (const db_con_t *handle, const db_key_t *keys, const db_val_t *vals, const int n) |
| Just like insert, but replace the row if it exists. | |
| int | db_mysql_update (const db_con_t *_h, const db_key_t *_k, const db_op_t *_o, const db_val_t *_v, const db_key_t *_uk, const db_val_t *_uv, const int _n, const int _un) |
| Update a row in table. | |
| int | db_mysql_use_table (db_con_t *_h, const str *_t) |
| Store name of table that will be used by subsequent database functions. | |
Module: DB_MYSQL :: the MySQL driver for Kamailio.
Definition in file db_mysql/dbase.h.
| int db_insert_update | ( | const db_con_t * | _h, | |
| const db_key_t * | _k, | |||
| const db_val_t * | _v, | |||
| const int | _n | |||
| ) |
Insert a row into table, update on duplicate key.
Insert a row into a specified table, update on duplicate key.
| _h | structure representing database connection | |
| _k | key names | |
| _v | values of the keys | |
| _n | number of key=value pairs |
Definition at line 475 of file db_mysql/dbase.c.
References CON_TABLE, db_mysql_submit_query(), db_mysql_val2str(), db_print_columns(), db_print_set(), db_print_values(), _str::len, len, LM_ERR, _str::s, s, snprintf, sql_buf, SQL_BUF_LEN, and sql_str.
Referenced by db_mysql_bind_api().
| int db_last_inserted_id | ( | const db_con_t * | _h | ) |
Returns the last inserted ID.
Returns the last inserted ID.
| _h | database handle |
Definition at line 458 of file db_mysql/dbase.c.
References CON_CONNECTION, and LM_ERR.
Referenced by db_mysql_bind_api().
| void db_mysql_close | ( | db_con_t * | _h | ) |
Close a database connection.
Shut down the database module. No function should be called after this
| _h | handle to the closed connection |
Definition at line 140 of file db_mysql/dbase.c.
References db_do_close(), and db_mysql_free_connection().
Referenced by db_mysql_bind_api().
| int db_mysql_delete | ( | const db_con_t * | _h, | |
| const db_key_t * | _k, | |||
| const db_op_t * | _o, | |||
| const db_val_t * | _v, | |||
| const int | _n | |||
| ) |
Delete a row from table.
Delete a row from the specified table
| _h | structure representing database connection | |
| _k | key names | |
| _o | operators | |
| _v | values of the keys that must match | |
| _n | number of key=value pairs |
Definition at line 408 of file db_mysql/dbase.c.
References db_do_delete(), db_mysql_submit_query(), and db_mysql_val2str().
Referenced by db_mysql_bind_api().
fetch rows from a result
fetch rows from a result
Gets a partial result set, fetch a number of rows from a database result. This function initialize the given result structure on the first run, and fetches the nrows number of rows. On subsequenting runs, it uses the existing result and fetches more rows, until it reaches the end of the result set. Because of this the result needs to be null in the first invocation of the function. If the number of wanted rows is zero, the function returns anything with a result of zero.
| _h | structure representing the database connection | |
| _r | pointer to a structure representing the result | |
| nrows | number of fetched rows |
Definition at line 269 of file db_mysql/dbase.c.
References CON_CONNECTION, CON_RESULT, CON_ROW, db_free_result(), db_free_rows(), db_mysql_convert_row(), db_mysql_get_columns(), db_new_result(), LM_DBG, LM_ERR, pkg_malloc, RES_LAST_ROW, RES_NUM_ROWS, RES_ROW_N, and RES_ROWS.
Referenced by db_mysql_bind_api().
Free all memory allocated by get_result.
Release a result set from memory.
| _h | handle to the database | |
| _r | result set that should be freed |
Definition at line 216 of file db_mysql/dbase.c.
References CON_RESULT, db_free_result(), and LM_ERR.
Referenced by db_mysql_bind_api().
Initialize database connection.
Initialize the database module. No function should be called before this
| _url | URL used for initialization |
Definition at line 128 of file db_mysql/dbase.c.
References db_do_init(), and db_mysql_new_connection().
Referenced by db_mysql_bind_api().
Insert a row into table.
Insert a row into a specified table.
| _h | structure representing database connection | |
| _k | key names | |
| _v | values of the keys | |
| _n | number of key=value pairs |
Definition at line 392 of file db_mysql/dbase.c.
References db_do_insert(), db_mysql_submit_query(), and db_mysql_val2str().
Referenced by db_mysql_bind_api().
| int db_mysql_query | ( | const db_con_t * | _h, | |
| const db_key_t * | _k, | |||
| const db_op_t * | _op, | |||
| const db_val_t * | _v, | |||
| const db_key_t * | _c, | |||
| const int | _n, | |||
| const int | _nc, | |||
| const db_key_t | _o, | |||
| db_res_t ** | _r | |||
| ) |
Do a query.
Query a table for specified rows.
| _h | structure representing database connection | |
| _k | key names | |
| _op | operators | |
| _v | values of the keys that must match | |
| _c | column names to return | |
| _n | number of key=values pairs to compare | |
| _nc | number of columns to return | |
| _o | order by the specified column | |
| _r | pointer to a structure representing the result |
Definition at line 246 of file db_mysql/dbase.c.
References db_do_query(), db_mysql_store_result(), db_mysql_submit_query(), and db_mysql_val2str().
Referenced by db_mysql_bind_api().
Raw SQL query.
Execute a raw SQL query.
| _h | handle for the database | |
| _s | raw query string | |
| _r | result set for storage |
Definition at line 377 of file db_mysql/dbase.c.
References db_do_raw_query(), db_mysql_store_result(), and db_mysql_submit_query().
Referenced by db_mysql_bind_api().
| int db_mysql_replace | ( | const db_con_t * | _h, | |
| const db_key_t * | _k, | |||
| const db_val_t * | _v, | |||
| const int | _n | |||
| ) |
Just like insert, but replace the row if it exists.
Just like insert, but replace the row if it exists.
| _h | database handle | |
| _k | key names | |
| _v | values of the keys that must match | |
| _n | number of key=value pairs |
Definition at line 445 of file db_mysql/dbase.c.
References db_do_replace(), db_mysql_submit_query(), and db_mysql_val2str().
Referenced by db_mysql_bind_api().
| int db_mysql_update | ( | const db_con_t * | _h, | |
| const db_key_t * | _k, | |||
| const db_op_t * | _o, | |||
| const db_val_t * | _v, | |||
| const db_key_t * | _uk, | |||
| const db_val_t * | _uv, | |||
| const int | _n, | |||
| const int | _un | |||
| ) |
Update a row in table.
Update some rows in the specified table
| _h | structure representing database connection | |
| _k | key names | |
| _o | operators | |
| _v | values of the keys that must match | |
| _uk | updated columns | |
| _uv | updated values of the columns | |
| _n | number of key=value pairs | |
| _un | number of columns to update |
Definition at line 428 of file db_mysql/dbase.c.
References db_do_update(), db_mysql_submit_query(), and db_mysql_val2str().
Referenced by db_mysql_bind_api().
Store name of table that will be used by subsequent database functions.
Store the name of table that will be used by subsequent database functions
| _h | database handle | |
| _t | table name |
Definition at line 533 of file db_mysql/dbase.c.
References db_use_table().
Referenced by db_mysql_bind_api().
1.5.6