[Dbix-class] Relationship problems
Josef Karthauser
joe at tao.org.uk
Sat Nov 11 01:17:17 GMT 2006
On Sat, Nov 11, 2006 at 12:22:35AM +0000, Jess Robinson wrote:
>
> Should be:
> __PACKAGE__->has_many(domains => 'Domain',
> { 'foreign.registrant' => 'self.contactid',
> 'foreign.owner' => 'self.owner' } );
>
> __PACKAGE__->belongs_to(registrant => 'Contact',
> { 'foreign.owner' => 'self.owner',
> 'foreign.contactid' => 'self.registrant' });
>
> > __PACKAGE__->belongs_to(contact => 'Tao::DBIx::Contact',
> > { ownerid => 'owner', contact => 'contactid' });
>
> You can figure this one out..
>
Okie; so are 'self' and 'foreign' magic labels?
How does that translate into prefetch calls? (code extract from
catalyst follows),
my $rs = $c->model('Contact')->
search($criteria,
{ page => $page, rows => 10,
order_by => [$order_by, $default_order, "domains.domainname"],
#1 prefetch => { 'domains' }
#2 prefetch => { 'domains' =>
#2 { 'self.contactid' => 'foreign.registrant',
#2 'self.owner' => 'foreign.owner' }}
});
Neither of #1 or #2 appear to do what I want. I get 'No such
relationship' whenever I try and process the request.
Am I missing a whole chunk of manual somewhere? I've scoured most of
it I think.
Joe
--
Josef Karthauser (joe at tao.org.uk) http://www.josef-k.net/
Physics Particle Theory (student) http://www.pact.cpes.sussex.ac.uk/
================ An eclectic mix of fact and theory. =================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://jules.scsys.co.uk/pipermail/dbix-class/attachments/20061111/63e019c9/attachment.pgp
More information about the Dbix-class
mailing list