Hi all.

I'm working on an object to handle synchronizing fields on a Gtk2::GladeXML - generated form with a database ( 2nd release is just around the corner ).

I need to get a field list when my object is created, however in some cases I'll be running a query which returns NO records on the first run.

I have bene using:

foreach my $field ( keys %{$self->{records}[$self->{position}]} ) {
   # do stuff
}

but this won't work if I don't have any records.

I only see 2 options:

1) Run a separate query with NO where clause and a LIMIT clause ( MySQL ) and get the field names from there, and then run the real query. This will work but I don't like it.

2) Keep a flag to indicate if I've done all the stuff in my loop ( which must happen only once ) and run it at the first opportunity ( the first time I run a query that gets results ). This is also a little messy, but better than option 1.

Is there any other way to get the field list without having any records?

Dan

Reply via email to