johnnywang has asked for the wisdom of the Perl Monks concerning the following question:
Let me be more specific, say I have two tables Foo and Bar, each has the same columns: id, name. I have a standard perl object mapping to the table:
and if I skip the first query, then $bar1 and $bar2 are correct.package FooBar; use strict; use base 'Class::DBI'; FooBar->set_db('Main','dburl','user','password'); FooBar->table('Foo'); # Foo is the default table FooBar->columns(Primary=> qw/id/ ); FooBar->columns(Other=> qw/name/ ); package main; my $foo = FooBar->retrieve(1); print $foo->name(), "\n"; FooBar->table('Bar'); #switch table my $bar1 = FooBar->retrieve(1); # this give the same as $foo, it shoul +dn't. my $bar2 = FooBar->retrieve(2); # this is different
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dynamically change tables for Class::DBI
by perrin (Chancellor) on Feb 18, 2005 at 21:25 UTC | |
by johnnywang (Priest) on Feb 18, 2005 at 21:45 UTC | |
by perrin (Chancellor) on Feb 18, 2005 at 21:55 UTC |