On 5/25/06, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
C->get_c(
query=> [
id => 1,
],
require_objects => [ 'B' , 'A' ],
);
where A isn't defined in C, but is a FKEY in class B
$cs = C->get_c(query => [ id => 1 ],
require_objects => [ 'B.A' ]);
Then, to get at the A object:
foreach my $c (@$cs)
{
$a = $c->b->a; # no database hit, data already loaded
}
If you're really loading just one object by primary key and don't mind
if it doesn't have both a B and an A, you can do this instead:
$c = C->new(id => 1)->load(with => 'B.A');
which will do (roughly) the equivalent of
$cs = C->get_c(query => [ id => 1 ],
with_objects => [ 'B.A' ]);
$c = $c->[0];
This "dot-chaining" of relationship names in with_objects and
require_objects parameter values is demonstrated in the tutorial
section linked earlier. Search for the string "'vendor.region'" to
find the example.
-John
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object