I have been using Class::Struct a lot recently and instantiating an array
object with it. You can also use a hash if you wish. This type of object
gives you a C-like structure that you can manipulate as either an array
(hash) or as a regular object using automatically generated
accessor/mutator functions.
When defining the structure, you set up a call to struct and list the
elements (keys) you want in your object. For each DB table, create a
class whose attributes (array elements/hash keys, whatever you want to
call it) match the columns of your table. Then just instantiate the
appropriate class and when doing a fetch, feed the results to your object.
Take a look at the perldoc for Class::Struct... it might do the trick for
you.
HTH,
Curt
On Mon, 4 Jun 2001, Mohammad Shoja wrote:
> Hi folks,
> I am using dbi with mysql to develope a data access interface for my
> application,
> and also I am using hash to retriving rows from database using
> fetchrow_hashref function,
> everything is fine, But the problem is I have to redefine a hash for every
> table which I am working with each time and in each function.
> how can I bypass this, just like using structure in C. to defining it once
> and using it as a data type.
> I know that I can implement it in Object oriented perl but How can I
> handle it in structured perl-dbi programming.
>
> Any help and suggestion appriciate.
> Thank you all in advance.
> regards
> ----------------------------------------------------------------------
> Mohammadreza Shojatalab
> European Bioinformatics Institute Tel: +44 (0)1223 494 669
>
> EMBL Outstation Fax: +44 (0)1223 494 468
>
> Wellcome Trust Genome Campus E-Mail: [EMAIL PROTECTED]
>
> Hinxton, Cambridge URL: http://www.ebi.ac.uk/~shoja
>
> CB10 1SD, UK
>
>