[Dbix-class] How to use a model with a different table name
Emmanuel Quevillon
tuco at pasteur.fr
Mon Jun 23 13:31:41 BST 2008
Hi,
I am facing a problem (maybe a newbie one).
I have a module DB::GenericTable.pm 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
$model->serach()
....
Thanks for any clue
Regards
--
-------------------------
Emmanuel Quevillon
Biological Software and Databases Group
Institut Pasteur
+33 1 44 38 95 98
tuco at_ pasteur dot fr
-------------------------
More information about the DBIx-Class
mailing list