swad-core/swad_database.h

85 lines
3.2 KiB
C
Raw Permalink Normal View History

2014-12-01 23:55:08 +01:00
// swad_database.h: database
#ifndef _SWAD_DB
#define _SWAD_DB
/*
SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
2014-12-01 23:55:08 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/*********************************** Headers *********************************/
/*****************************************************************************/
#include <mysql/mysql.h> // To access MySQL databases
#include "swad_role.h"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
void DB_CreateTablesIfNotExist (void);
void DB_OpenDBConnection (void);
bool DB_CheckIfDatabaseIsOpen (void);
2014-12-01 23:55:08 +01:00
void DB_CloseDBConnection (void);
2018-10-18 20:27:22 +02:00
2019-03-09 20:12:44 +01:00
void DB_BuildQuery (char **Query,const char *fmt,...);
2018-10-25 11:26:44 +02:00
2018-10-30 09:02:14 +01:00
unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
const char *fmt,...);
long DB_QuerySELECTCode (const char *MsgError,
const char *fmt,...);
unsigned DB_QuerySELECTUnsigned (const char *MsgError,
const char *fmt,...);
double DB_QuerySELECTDouble (const char *MsgError,
const char *fmt,...);
Rol_Role_t DB_QuerySELECTRole (const char *MsgError,
const char *fmt,...);
void DB_QuerySELECTString (char *Str,size_t StrSize,const char *MsgError,
const char *fmt,...);
long DB_GetNextCode (MYSQL_RES *mysql_res);
2018-11-04 20:51:38 +01:00
unsigned long DB_GetNumRowsTable (const char *Table);
2018-11-02 19:37:11 +01:00
unsigned long DB_QueryCOUNT (const char *MsgError,const char *fmt,...);
bool DB_QueryEXISTS (const char *MsgError,const char *fmt,...);
2018-10-18 20:27:22 +02:00
2018-11-02 19:37:11 +01:00
void DB_QueryINSERT (const char *MsgError,const char *fmt,...);
2018-10-18 20:27:22 +02:00
2018-11-03 01:45:36 +01:00
long DB_QueryINSERTandReturnCode (const char *MsgError,const char *fmt,...);
2018-10-18 20:27:22 +02:00
2018-11-02 16:39:35 +01:00
void DB_QueryREPLACE (const char *MsgError,const char *fmt,...);
2018-10-18 21:32:06 +02:00
2018-11-03 12:16:40 +01:00
void DB_QueryUPDATE (const char *MsgError,const char *fmt,...);
2018-10-18 20:27:22 +02:00
2018-11-02 22:00:31 +01:00
void DB_QueryDELETE (const char *MsgError,const char *fmt,...);
2018-10-18 20:27:22 +02:00
void DB_CreateTmpTable (const char *fmt,...);
void DB_DropTmpTable (const char *Table);
2018-11-02 22:41:02 +01:00
void DB_Query (const char *MsgError,const char *fmt,...);
2018-10-29 11:31:05 +01:00
2014-12-01 23:55:08 +01:00
void DB_FreeMySQLResult (MYSQL_RES **mysql_res);
void DB_ExitOnMySQLError (const char *Message);
void DB_SetThereAreLockedTables (void);
void DB_UnlockTables (void);
2014-12-01 23:55:08 +01:00
#endif