Hoel
C Database abstraction library with json based language
Functions
_h_result SQL query management functions

Functions

int h_execute_query (const struct _h_connection *conn, const char *query, struct _h_result *result, int options)
 
int h_query_insert (const struct _h_connection *conn, const char *query)
 
struct _h_datah_query_last_insert_id (const struct _h_connection *conn)
 
int h_query_update (const struct _h_connection *conn, const char *query)
 
int h_query_delete (const struct _h_connection *conn, const char *query)
 
int h_query_select (const struct _h_connection *conn, const char *query, struct _h_result *result)
 
int h_clean_result (struct _h_result *result)
 
int h_clean_data (struct _h_data *data)
 
int h_clean_data_full (struct _h_data *data)
 
int h_select_query_sqlite (const struct _h_connection *conn, const char *query, struct _h_result *result)
 
int h_execute_query_mariadb (const struct _h_connection *conn, const char *query, struct _h_result *result)
 
struct _h_datah_get_mariadb_value (const char *value, const unsigned long length, const int m_type)
 
int h_execute_query_pgsql (const struct _h_connection *conn, const char *query, struct _h_result *result)
 

Detailed Description

SQL query management for struct _h_result format

Function Documentation

◆ h_clean_data()

int h_clean_data ( struct _h_data data)

h_clean_data Free memory allocated by the struct _h_data

Parameters
datathe data to free
Returns
H_OK on success

h_clean_data Free memory allocated by the struct _h_data return H_OK on success

◆ h_clean_data_full()

int h_clean_data_full ( struct _h_data data)

h_clean_data_full Free memory allocated by the struct _h_data and the struct _h_data pointer

Parameters
datathe data to free
Returns
H_OK on success

h_clean_data_full Free memory allocated by the struct _h_data and the struct _h_data pointer return H_OK on success

◆ h_clean_result()

int h_clean_result ( struct _h_result result)

h_clean_result Free all the memory allocated by the struct _h_result

Parameters
resultthe result to free
Returns
H_OK on success

h_clean_result Free all the memory allocated by the struct _h_result

◆ h_execute_query()

int h_execute_query ( const struct _h_connection conn,
const char *  query,
struct _h_result result,
int  options 
)

h_execute_query Execute a query, set the result structure with the returned values if available if result is NULL, the query is executed but no value will be returned

Parameters
connthe connection to the database
querythe SQL query to execute
resultthe result structure to fill the result data
optionsoption to pass to the database engine options available H_OPTION_NONE (0): no option H_OPTION_SELECT: Execute a prepare statement (sqlite only) H_OPTION_EXEC: Execute an exec statement (sqlite only)
Returns
H_OK on success

h_execute_query Execute a query, set the result structure with the returned values if available if result is NULL, the query is executed but no value will be returned options available H_OPTION_NONE (0): no option H_OPTION_SELECT: Execute a prepare statement (sqlite only) H_OPTION_EXEC: Execute an exec statement (sqlite only) return H_OK on success

◆ h_execute_query_mariadb()

int h_execute_query_mariadb ( const struct _h_connection conn,
const char *  query,
struct _h_result result 
)

h_execute_query_mariadb Execute a select query on a mariadb connection, set the result structure with the returned values This is an internal function, you should use h_select_query instead Should not be executed by the user because all parameters are supposed to be correct if result is NULL, the query is executed but no value will be returned Useful for SELECT statements

Parameters
connthe connection to the database
querythe SQL query to execute
resulta _h_result that will be filled with the result
Returns
H_OK on success

◆ h_execute_query_pgsql()

int h_execute_query_pgsql ( const struct _h_connection conn,
const char *  query,
struct _h_result result 
)

h_execute_query_pgsql Execute a select query on a pgsql connection, set the result structure with the returned values This is an internal function, you should use h_select_query instead Should not be executed by the user because all parameters are supposed to be correct if result is NULL, the query is executed but no value will be returned Useful for SELECT statements

Parameters
connthe connection to the database
querythe SQL query to execute
resulta _h_result that will be filled with the result return H_OK on success

◆ h_get_mariadb_value()

struct _h_data* h_get_mariadb_value ( const char *  value,
const unsigned long  length,
const int  m_type 
)

h_get_mariadb_value convert value into a struct _h_data * depening on the m_type given This is an internal function, you should not use it returned value must be h_free'd with h_clean_data_full after use

Parameters
valuethe value to convert
lengththe length of the value
m_typethe data type
Returns
a _h_data * contaning the converted value

◆ h_query_delete()

int h_query_delete ( const struct _h_connection conn,
const char *  query 
)

h_query_delete Execute an delete query

Parameters
connthe connection to the database
querythe SQL query to execute
Returns
H_OK on success

h_query_delete Execute an delete query return H_OK on success

◆ h_query_insert()

int h_query_insert ( const struct _h_connection conn,
const char *  query 
)

h_query_insert Execute an insert query

Parameters
connthe connection to the database
querythe SQL query to execute
Returns
H_OK on success

h_query_insert Execute an insert query return H_OK on success

◆ h_query_last_insert_id()

struct _h_data* h_query_last_insert_id ( const struct _h_connection conn)

h_query_last_insert_id return the id of the last inserted value

Parameters
connthe connection to the database
Returns
a pointer to struct _h_data * on success, NULL otherwise.

h_query_last_insert_id return the id of the last inserted value return H_OK on success

◆ h_query_select()

int h_query_select ( const struct _h_connection conn,
const char *  query,
struct _h_result result 
)

h_query_select Execute a select query, set the result structure with the returned values

Parameters
connthe connection to the database
querythe SQL query to execute
resultthe result structure to fill the result data
Returns
H_OK on success

h_query_select Execute a select query, set the result structure with the returned values return H_OK on success

◆ h_query_update()

int h_query_update ( const struct _h_connection conn,
const char *  query 
)

h_query_update Execute an update query

Parameters
connthe connection to the database
querythe SQL query to execute
Returns
H_OK on success

h_query_update Execute an update query return H_OK on success

◆ h_select_query_sqlite()

int h_select_query_sqlite ( const struct _h_connection conn,
const char *  query,
struct _h_result result 
)

h_select_query_sqlite Execute a select query on a sqlite connection, set the result structure with the returned values This is an internal function, you should use h_select_query instead Should not be executed by the user because all parameters are supposed to be correct if result is NULL, the query is executed but no value will be returned Useful for SELECT statements

Parameters
connthe connection to the database
querythe SQL query to execute
resulta _h_result that will be filled with the result return H_OK on success