in reply to Re: parsing $sth-{NAMES}
in thread parsing $sth-{NAMES}

This is close to what I am looking for. I have been expirimenting all day. The overall story is that I have an object that I will populate the properties with data from the database. I was thinking if I named the properties with the same names for the columns in the tables, I could write a loop that populated each property with corresponding database values.

Replies are listed 'Best First'.
Re: Re: Re: parsing $sth-{NAMES}
by chromatic (Archbishop) on Mar 24, 2001 at 11:33 UTC
    My article on www.perl.com goes into some of the techniques, especially the one Masem describes. The last example does just what you say, and it's fairly speedy too. (I haven't benchmarked it, but it uses the fastest retrieval mechanisms together.)

    Wow... I feel like a merlyn or a Dominus. *sniffle*

Perl Object-Relational Technologies
by princepawn (Parson) on Mar 24, 2001 at 12:50 UTC
    The overall story is that I have an object that I will populate the properties with data from the database. I was thinking if I named the properties with the same names for the columns in the tables, I could write a loop that populated each property with corresponding database values.

    There are a number of object-relational technologies for Perl:

    1. Tangram
    2. BingoX::Carbon
    3. DBIx::Recordset
    4. Alzabo
    5. Class::DBI
    6. Class::SPOPS

    It really depends on what you want to do exactly... but the simplest thing is to use DBI as these people said and simply perlfunc:bless the hashref into the desired class.

      Actually, that's just SPOPS rather than Class::SPOPS -- although I'm happy that someone mentioned it :-)

      Chris
      M-x auto-bs-mode