Re: Database interaction



* Daniel Kasak <dkasak nusconsulting com au> [2004-04-28 01:24]:
Thanks for the tips. I've been at this for 7 years now, 5 of
which I've spent mostly with MySQL. I'm certainly no beginner
wanting to do a home recipe collection.

No offense, but that's what it sounded like. You gave no
indication of what it really was you were trying to do. Sorry for
the misunderstanding.

You're missing the point. I want an object that will automate
the binding of input fields to data in our database.

Aha. Now you're clearer.

Other way around dude. The database is very much in existance
already. 

That's not something you mentioned before..

I then go into glade and create entry fields, and call them:

[...]

Then I add my DB interaction object to the window. When the
windows opens, I call the 'refresh' method, which looks at it's
SQL and DB string and fetches the data via DBI. It then looks
at the list of fields is has, and looks at the fields that are
on the same window that it's on, and sets their value
accordingly. See how it saves programming time?

That sounds backwards to me. You haven't automated very much; you
still have to manually create a form for every single table.

If I were to tackle this, I'd write a container widget which is
given a list of fields (and their data types), which then
automatically instantiates suitable widgets for all the fields.

It wouldn't be hard to pass coderefs to do validation for each
field.

The object has an 'update' method, which will do the opposite.
It will loop through all fields on the form associated with it
by name, and run an update command on the DB based on the
primary key.

A container widget as I described above should probably be
implemented without any database related code at all, in the
interest of reusability. Instead, it should just offer a way to
get the values for all the fields at once.  For applications such
as yours, there are SQL asbtraction modules which can take this
list and munge it into a query.

That would be a way to cleanly separate the GUI from the backend.

Of course, no such widget exists..

-- 
Regards,
Aristotle
 
"If you can't laugh at yourself, you don't take life seriously enough."



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]