Created
May 29, 2014 20:12
-
-
Save hub-cap/b9e5059196865f25c430 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffi.cdef[[ | |
typedef void MYSQL; | |
typedef void MYSQL_RES; | |
typedef char **MYSQL_ROW; | |
enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, | |
MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG, | |
MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE, | |
MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP, | |
MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24, | |
MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, | |
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, | |
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, | |
MYSQL_TYPE_BIT, | |
MYSQL_TYPE_NEWDECIMAL=246, | |
MYSQL_TYPE_ENUM=247, | |
MYSQL_TYPE_SET=248, | |
MYSQL_TYPE_TINY_BLOB=249, | |
MYSQL_TYPE_MEDIUM_BLOB=250, | |
MYSQL_TYPE_LONG_BLOB=251, | |
MYSQL_TYPE_BLOB=252, | |
MYSQL_TYPE_VAR_STRING=253, | |
MYSQL_TYPE_STRING=254, | |
MYSQL_TYPE_GEOMETRY=255 | |
}; | |
typedef struct st_mysql_field { | |
char *name; /* Name of column */ | |
char *org_name; /* Original column name, if an alias */ | |
char *table; /* Table of column if column was a field */ | |
char *org_table; /* Org table name, if table was an alias */ | |
char *db; /* Database for table */ | |
char *catalog; /* Catalog for table */ | |
char *def; /* Default value (set by mysql_list_fields) */ | |
unsigned long length; /* Width of column (create length) */ | |
unsigned long max_length; /* Max width for selected set */ | |
unsigned int name_length; | |
unsigned int org_name_length; | |
unsigned int table_length; | |
unsigned int org_table_length; | |
unsigned int db_length; | |
unsigned int catalog_length; | |
unsigned int def_length; | |
unsigned int flags; /* Div flags */ | |
unsigned int decimals; /* Number of decimals in field */ | |
unsigned int charsetnr; /* Character set */ | |
enum enum_field_types type; /* Type of field. See mysql_com.h for types */ | |
void *extension; | |
} MYSQL_FIELD; | |
...... | |
unsigned int mysql_num_fields(MYSQL_RES *res); | |
MYSQL_ROW mysql_fetch_row(MYSQL_RES *result); | |
MYSQL_FIELD* mysql_fetch_fields(MYSQL_RES *result); | |
...... | |
]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
local nfields = clib.mysql_num_fields(result)
local cols = clib.mysql_fetch_fields(result)