[Dbix-class] Relationship problems
Josef Karthauser
joe at tao.org.uk
Sat Nov 11 19:12:38 GMT 2006
On Sat, Nov 11, 2006 at 01:17:17AM +0000, Josef Karthauser wrote:
> 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.
>
Ahha, got it.
What I wanted was:
my $rs = $c->model('Contact')->
search($criteria,
{ page => $page, rows => 10,
order_by => [$order_by, $default_order, "domains.domainname"],
prefetch => 'domains'
}
});
This now works, as the relationships are correctly described in the
class files. However I would have thought that #2 should have
worked too; I'd appreciate some understanding on that count. The
self. and foreign. functionality I don't think is clearly deliniated
in the documentation. (For instance when I read that I assumed
that I needed to replace self with the local table name and foreign
with the foreign table name, but that didn't work).
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/000934f1/attachment.pgp
More information about the Dbix-class
mailing list