km_dbase.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 "../../str.h"
  38. /*! \brief
  39. * Initialize database connection
  40. */
  41. db1_con_t* db_mysql_init(const str* _sqlurl);
  42. /*! \brief
  43. * Close a database connection
  44. */
  45. void db_mysql_close(db1_con_t* _h);
  46. /*! \brief
  47. * Free all memory allocated by get_result
  48. */
  49. int db_mysql_free_result(const db1_con_t* _h, db1_res_t* _r);
  50. /*! \brief
  51. * Do a query
  52. */
  53. int db_mysql_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
  54. const db_val_t* _v, const db_key_t* _c, const int _n, const int _nc,
  55. const db_key_t _o, db1_res_t** _r);
  56. /*! \brief
  57. * fetch rows from a result
  58. */
  59. int db_mysql_fetch_result(const db1_con_t* _h, db1_res_t** _r, const int nrows);
  60. /*! \brief
  61. * Raw SQL query
  62. */
  63. int db_mysql_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
  64. /*! \brief
  65. * Insert a row into table
  66. */
  67. int db_mysql_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v, const int _n);
  68. /*! \brief
  69. * Delete a row from table
  70. */
  71. int db_mysql_delete(const db1_con_t* _h, const db_key_t* _k, const
  72. db_op_t* _o, const db_val_t* _v, const int _n);
  73. /*! \brief
  74. * Update a row in table
  75. */
  76. int db_mysql_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
  77. const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv, const int _n,
  78. const int _un);
  79. /*! \brief
  80. * Just like insert, but replace the row if it exists
  81. */
  82. int db_mysql_replace(const db1_con_t* handle, const db_key_t* keys,
  83. const db_val_t* vals, const int n, const int _un, const int _m);
  84. /*! \brief
  85. * Returns the last inserted ID
  86. */
  87. int db_mysql_last_inserted_id(const db1_con_t* _h);
  88. /*! \brief
  89. * Returns number of affected rows for last query
  90. */
  91. int db_mysql_affected_rows(const db1_con_t* _h);
  92. /*! \brief
  93. * Insert a row into table, update on duplicate key
  94. */
  95. int db_mysql_insert_update(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
  96. const int _n);
  97. /*! \brief
  98. * Insert a row into table
  99. */
  100. int db_mysql_insert_delayed(const db1_con_t* _h, const db_key_t* _k,
  101. const db_val_t* _v, const int _n);
  102. /*! \brief
  103. * Store name of table that will be used by
  104. * subsequent database functions
  105. */
  106. int db_mysql_use_table(db1_con_t* _h, const str* _t);
  107. #endif /* KM_DBASE_H */