km_dbase.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * $Id$
  3. *
  4. * MySQL module core functions
  5. *
  6. * Copyright (C) 2001-2003 FhG Fokus
  7. * Copyright (C) 2008 1&1 Internet AG
  8. *
  9. * This file is part of Kamailio, a free SIP server.
  10. *
  11. * Kamailio is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version
  15. *
  16. * Kamailio is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. */
  25. /*! \file
  26. * \brief DB_MYSQL :: Core
  27. * \ingroup db_mysql
  28. * Module: \ref db_mysql
  29. */
  30. #ifndef KM_DBASE_H
  31. #define KM_DBASE_H
  32. #include "../../lib/srdb1/db_con.h"
  33. #include "../../lib/srdb1/db_res.h"
  34. #include "../../lib/srdb1/db_key.h"
  35. #include "../../lib/srdb1/db_op.h"
  36. #include "../../lib/srdb1/db_val.h"
  37. #include "../../lib/srdb1/db_locking.h"
  38. #include "../../str.h"
  39. /*! \brief
  40. * Initialize database connection
  41. */
  42. db1_con_t* db_mysql_init(const str* _sqlurl);
  43. /*! \brief
  44. * Close a database connection
  45. */
  46. void db_mysql_close(db1_con_t* _h);
  47. /*! \brief
  48. * Free all memory allocated by get_result
  49. */
  50. int db_mysql_free_result(const db1_con_t* _h, db1_res_t* _r);
  51. /*! \brief
  52. * Do a query
  53. */
  54. int db_mysql_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
  55. const db_val_t* _v, const db_key_t* _c, const int _n, const int _nc,
  56. const db_key_t _o, db1_res_t** _r);
  57. /*! \brief
  58. * fetch rows from a result
  59. */
  60. int db_mysql_fetch_result(const db1_con_t* _h, db1_res_t** _r, const int nrows);
  61. /*! \brief
  62. * Raw SQL query
  63. */
  64. int db_mysql_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
  65. /*! \brief
  66. * Raw SQL query via async framework
  67. */
  68. int db_mysql_raw_query_async(const db1_con_t* _h, const str* _s);
  69. /*! \brief
  70. * Insert a row into table
  71. */
  72. int db_mysql_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v, const int _n);
  73. /*! \brief
  74. * Delete a row from table
  75. */
  76. int db_mysql_delete(const db1_con_t* _h, const db_key_t* _k, const
  77. db_op_t* _o, const db_val_t* _v, const int _n);
  78. /*! \brief
  79. * Update a row in table
  80. */
  81. int db_mysql_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
  82. const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv, const int _n,
  83. const int _un);
  84. /*! \brief
  85. * Just like insert, but replace the row if it exists
  86. */
  87. int db_mysql_replace(const db1_con_t* handle, const db_key_t* keys,
  88. const db_val_t* vals, const int n, const int _un, const int _m);
  89. /*! \brief
  90. * Returns the last inserted ID
  91. */
  92. int db_mysql_last_inserted_id(const db1_con_t* _h);
  93. /*! \brief
  94. * Returns number of affected rows for last query
  95. */
  96. int db_mysql_affected_rows(const db1_con_t* _h);
  97. /*! \brief
  98. * Starts transaction
  99. */
  100. int db_mysql_start_transaction(db1_con_t* _h, db_locking_t _l);
  101. /*! \brief
  102. * Commits transaction
  103. */
  104. int db_mysql_end_transaction(db1_con_t* _h);
  105. /*! \brief
  106. * Aborts transaction
  107. */
  108. int db_mysql_abort_transaction(db1_con_t* _h);
  109. /*! \brief
  110. * Insert a row into table, update on duplicate key
  111. */
  112. int db_mysql_insert_update(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
  113. const int _n);
  114. /*! \brief
  115. * Insert a row into table
  116. */
  117. int db_mysql_insert_delayed(const db1_con_t* _h, const db_key_t* _k,
  118. const db_val_t* _v, const int _n);
  119. /*! \brief
  120. * Insert a row into table via async framework
  121. */
  122. int db_mysql_insert_async(const db1_con_t* _h, const db_key_t* _k,
  123. const db_val_t* _v, const int _n);
  124. /*! \brief
  125. * Store name of table that will be used by
  126. * subsequent database functions
  127. */
  128. int db_mysql_use_table(db1_con_t* _h, const str* _t);
  129. #endif /* KM_DBASE_H */