Re: How to use a model with a different table name

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: How to use a model with a different table name

Matt S Trout
On Mon, Jun 23, 2008 at 02:31:41PM +0200, Emmanuel Quevillon wrote:

> Hi,
> I am facing a problem (maybe a newbie one).
> I have a module which reflects a
> 'generic' table schema into my database associated to a
> table name in the DB.
> I'd like to kow how can I access another table (different
> name) but with the same schema (same column name, same
> datatype) from my perl module? Someting like
> package DB::GenericTable;
> use strict;
> use warnings;
> use base 'DBIx::Class';
> __PACKAGE__->load_components("Core");
> __PACKAGE__->table("genericname");
> __PACKAGE__->add_columns(
> ...
> );
> 1;
> Later in my code :
> my $model = $schema->resultset('GenericTable');
> $model->table('my_other_table_name'); #Point to another table



Though I think you're probably insane and creating subclasses is going
to be better. Maybe if you explained the use case better?

      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director          
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?  

Searchable Archive: