Re: [CDBI] multiple tables with same structure

"Juan Camacho" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
On 9/18/06, Ben Lavender <[email protected]> wrote:
> Hi all,
>
> But that is, naturally, only half the battle when dealing with CDBI,
> for the obvious reason that CDBI maps classes to table.  I'm basically
> trying to find a way to tell CDBI to fetch an object of type x from
> table y, and the next time the script is run it might be table z, but
> the object will still be of type x.
>

Have you tried changing the table name at run-time? e.g.
  package main;
  use Music::Artist;
  Music::Artist->table('z').

Not sure how much havoc the above will cause given you are messing
with class data, but it should work for simple cases, e.g. search,
retrieve, retrieve_all scenarios.

Also, see "Using multiple databases" Wiki entry at
http://wiki.class-dbi.com/wiki/Using_multiple_databases
It doesn't necessarily address your issue directly, but maybe you'll
get some inspiration from it :)

Also investigate using alternative packages Rose::DB or DBIx::Class
instead of CDBI.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.