Michael Van Canneyt
michael.vancanneyt at wisa.be
Thu Jul 4 09:48:46 CEST 2002
On Thu, 4 Jul 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.
After the query has been run, run mysql_num_fields to get the number of
fields. Then, for each field, run mysql_fetch_field to retrieve a
pointer to a record describing the fields. This includes the field
name. This way you can fill an array of field names and do the inverse
search: for a field name, find the index in the array - this is easy.
Or you can use TDataset, which does all of this for you.
More information about the fpc-pascal