km_dbase.h 3.9 KB

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