in reply to OO Coding - way to make it "save" the values?

sub table { my ($self,$table) = @_; $self->{table} = $table; return $self; }

Since this method returns $self, both $tbl1 and $tbl2 are actually the same object.

A good solution would be to distinguish between database and table objects. Or use DBIx::Class right away.

Replies are listed 'Best First'.
Re^2: OO Coding - way to make it "save" the values?
by ultranerds (Hermit) on Jul 27, 2011 at 12:04 UTC
    Hi,

    Thanks. I don't really wanna use another DBI module, as I wanna try and play around with how this OO stuff works :) (as I said, its only a personal project). Gonna have a look at a way to distingish between the tables now

    Thanks for the reply

    Andy

      Here is hint

      sub table { return AndySQL::Table->new( db => shift, tablename => shift ); }

      ultranerds, I highly suggest a reading of Beginning Perl Chapter 11: Object-Oriented Perl, followed by the Objects chapter of Modern Perl

        Hi,

        Thanks, I've actually read the one in Beginning Per, but not the "Modern Perl" one... I'll get that book on order now

        Regarding your suggestion - thats, I'll give that a go :)

        Cheers

        Andy
        Sweet, I got it working - thanks for the help :)
Re^2: OO Coding - way to make it "save" the values?
by ultranerds (Hermit) on Jul 27, 2011 at 12:18 UTC
    Mmm, I'm struggling to come up with a way to do this. Any pointers?

    TIA

    Andy