modules/db_mysql/km_dbase.h
4f778298
 /*
  * MySQL module core functions
  *
  * Copyright (C) 2001-2003 FhG Fokus
  * Copyright (C) 2008 1&1 Internet AG
  *
31f52f1d
  * This file is part of Kamailio, a free SIP server.
4f778298
  *
31f52f1d
  * Kamailio is free software; you can redistribute it and/or modify
4f778298
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
  *
31f52f1d
  * Kamailio is distributed in the hope that it will be useful,
4f778298
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * 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 
9e1ff448
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
4f778298
  */
 
083502f8
 /*! \file
  *  \brief DB_MYSQL :: Core
  *  \ingroup db_mysql
  *  Module: \ref db_mysql
  */
 
 
4f778298
 
96121273
 #ifndef KM_DBASE_H
 #define KM_DBASE_H
4f778298
 
 
96121273
 #include "../../lib/srdb1/db_con.h"
 #include "../../lib/srdb1/db_res.h"
 #include "../../lib/srdb1/db_key.h"
 #include "../../lib/srdb1/db_op.h"
 #include "../../lib/srdb1/db_val.h"
fe977dfc
 #include "../../lib/srdb1/db_locking.h"
4f778298
 #include "../../str.h"
 
083502f8
 /*! \brief
4f778298
  * Initialize database connection
  */
956802dc
 db1_con_t* db_mysql_init(const str* _sqlurl);
4f778298
 
 
083502f8
 /*! \brief
4f778298
  * Close a database connection
  */
956802dc
 void db_mysql_close(db1_con_t* _h);
4f778298
 
 
083502f8
 /*! \brief
4f778298
  * Free all memory allocated by get_result
  */
94ce2b1d
 int db_mysql_free_result(const db1_con_t* _h, db1_res_t* _r);
4f778298
 
 
083502f8
 /*! \brief
4f778298
  * Do a query
  */
956802dc
 int db_mysql_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
4f778298
 	     const db_val_t* _v, const db_key_t* _c, const int _n, const int _nc,
f1fc20c7
 	     const db_key_t _o, db1_res_t** _r);
4f778298
 
 
083502f8
 /*! \brief
4f778298
  * fetch rows from a result
  */
f1fc20c7
 int db_mysql_fetch_result(const db1_con_t* _h, db1_res_t** _r, const int nrows);
4f778298
 
 
083502f8
 /*! \brief
4f778298
  * Raw SQL query
  */
f1fc20c7
 int db_mysql_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
4f778298
 
 
0d78e9a9
 /*! \brief
  * Raw SQL query via async framework
  */
 int db_mysql_raw_query_async(const db1_con_t* _h, const str* _s);
 
 
083502f8
 /*! \brief
4f778298
  * Insert a row into table
  */
956802dc
 int db_mysql_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v, const int _n);
4f778298
 
 
083502f8
 /*! \brief
4f778298
  * Delete a row from table
  */
956802dc
 int db_mysql_delete(const db1_con_t* _h, const db_key_t* _k, const 
4f778298
 	db_op_t* _o, const db_val_t* _v, const int _n);
 
 
083502f8
 /*! \brief
4f778298
  * Update a row in table
  */
956802dc
 int db_mysql_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
4f778298
 	const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv, const int _n,
 	const int _un);
 
 
083502f8
 /*! \brief
4f778298
  * Just like insert, but replace the row if it exists
  */
aac61596
 int db_mysql_replace(const db1_con_t* handle, const db_key_t* keys,
 		const db_val_t* vals, const int n, const int _un, const int _m);
4f778298
 
083502f8
 /*! \brief
4f778298
  * Returns the last inserted ID
  */
a001f2f2
 int db_mysql_last_inserted_id(const db1_con_t* _h);
4f778298
 
588d1ffb
 
 /*! \brief
  * Returns number of affected rows for last query
  */
 int db_mysql_affected_rows(const db1_con_t* _h);
 
fe977dfc
 /*! \brief
  * Starts transaction
  */
 int db_mysql_start_transaction(db1_con_t* _h, db_locking_t _l);
 
 /*! \brief
  * Commits transaction
  */
 int db_mysql_end_transaction(db1_con_t* _h);
 
 /*! \brief
  * Aborts transaction
  */
 int db_mysql_abort_transaction(db1_con_t* _h);
 
588d1ffb
 
083502f8
 /*! \brief
4f778298
  * Insert a row into table, update on duplicate key
  */
a001f2f2
 int db_mysql_insert_update(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
4f778298
 	const int _n);
 
 
4c7c1b81
 /*! \brief
  * Insert a row into table
  */
 int db_mysql_insert_delayed(const db1_con_t* _h, const db_key_t* _k,
 		const db_val_t* _v, const int _n);
 
 
0d78e9a9
 /*! \brief
  * Insert a row into table via async framework
  */
 int db_mysql_insert_async(const db1_con_t* _h, const db_key_t* _k,
 		const db_val_t* _v, const int _n);
 
 
083502f8
 /*! \brief
4f778298
  * Store name of table that will be used by
  * subsequent database functions
  */
956802dc
 int db_mysql_use_table(db1_con_t* _h, const str* _t);
4f778298
 
 
96121273
 #endif /* KM_DBASE_H */