mirek.novak at auto.cz
Thu Jul 4 09:46:04 CEST 2002
Rainer Hantsch wrote:
> Hello, everybody!
> Currently I am thinking about enhancing my MySQL unit, because it currently
> does only a very simple way of querying. I use Michael's "mysql" unit and made
> another "layer" on top of it, preventing me from doing too much particular
> things repeatedly.
> My biggest problem is that this mysql unit returns the data in form of an
> array [0..n], which does not really make it easier to pick out a particular
> field. So I want to write a function which gets a field name passed and
> returns me the content. For that purpose I need to query the field names of a
> table, but I do not know, HOW.
> Can somebody help, please?
> Ing. Rainer Hantsch
Take a look at mysql manual in section Mysql API - MySql C API u have list of functions with small examples - all u need. In your
case U probably need function mysql_fetch_fields(...)
MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *result)
Returns an array of all MYSQL_FIELD structures for a result set. Each structure provides
nition for one column of the result set.
An array of MYSQL_FIELD structures for all columns of a result set.
unsigned int num_fields;
unsigned int i;
num_fields = mysql_num_fields(result);
fields = mysql_fetch_fields(result);
for(i = 0; i < num_fields; i++)
printf("Field %u is %s\n", i, fields[i].name);
jabber:mirek at njs.netlab.cz
More information about the fpc-pascal