Add helper function for reading values by field name

The helper function provides map-like access to row values. This is used
to retrieve the values for all MariaDB 10.0+ versions as there are
differences in the returned results between 10.1 and 10.2.
This commit is contained in:
Markus Mäkelä
2017-10-27 12:33:56 +03:00
parent 2d1e5f46fa
commit 0bc439641a
3 changed files with 36 additions and 8 deletions

View File

@ -66,6 +66,17 @@ int mxs_mysql_query(MYSQL* conn, const char* query);
*/
bool mxs_mysql_trim_quotes(char *s);
/**
* Helper function for getting values by field name
*
* @param result Resultset
* @param row Row where the value is read
* @param key Name of the field
*
* @return The value of the field or NULL if value is not found. NULL values
* are also returned as NULL pointers.
*/
const char* mxs_mysql_get_value(MYSQL_RES* result, MYSQL_ROW row, const char* key);
typedef enum mxs_pcre_quote_approach
{