[Catalyst] connecting to more than one database

Oleg Pronin syber.rus at gmail.com
Thu Jul 3 13:15:03 BST 2008


How do you imagine yourself a request with join beetween 2 tables in
different databases?
This is the reason you can't make relationships between different schemas.

2008/7/3 jagdish eashwar <jagdish.eashwar at gmail.com>:

> I am working on two Catalyst applications and had earlier set up separate
> Mysql databases for each of them. Since some of the tables that these two
> applications use, are the same, I put the common tables in a third databa=
se
> and created two models in each of the Catalyst applications. I am, howeve=
r,
> unable to set up  relationships between  tables in the common and specific
> databases.
>
> I used myapp_create.pl to create the two models:
>
> perl script/hardware_create.pl model MyhardwareDB DBIC::Schema
> Myhardware::Schema::MyhardwareDB create=3Dstatic dbi:mysql:hardware 'jag'
> 'passwd' '{ AutoCommit =3D> 1 }'
>
> perl script/hardware_create.pl model CommonDB DBIC::Schema
> Myhardware::Schema::CommonDB create=3Dstatic dbi:mysql:hardware 'jag' 'pa=
sswd'
> '{ AutoCommit =3D> 1 }'
>
> and then put in the relationships between the employee and hardware tables
> as under:
>
> # in Emp.pm
> #employee has many hardware
> __PACKAGE__->has_many(emp_hm_hw =3D>
> 'Myhardware::Schema::MyhardwareDB::Hardware', 'hw_emp_id');
>
> # in Hardware.pm
> #hardware belongs to employee
> __PACKAGE__->belongs_to(hw_bt_emp_id =3D>
> 'Myhardware::Schema::CommonDB::Emp','hw_emp_id');
>
> When I use these accessors in the tt2 templates, i get an undef error.
>
> undef error - DBIx::Class::Relationship::Accessor::__ANON__(): Can't find
> source for Myhardware::Schema::MyhardwareDB::Hardware at
> /home/jag/catalyst_trials/Myhardware/root/src/usr_fragment.tt2 line 8
>
> What am I doing wrong?
>
> Jagdish
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080703/ab106=
17a/attachment.htm


More information about the Catalyst mailing list