Per
http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Relationship/Base.pm#condition,
under "To specify joins which describe more than a simple equality of column
values, the custom join condition coderef syntax can be used. For example:"
__PACKAGE__->has_many(
"useraccounts", "UserAccounts"
sub {
my $args = shift;
return {
"$args->{foreign_alias}.userid" => { -ident =>
"$args->{self_alias}.id" },
"$args->{foreign_alias}.accountid" => { '=', $value },
};
}
);
not sure where the join_type will go, but that should be the gist.
Justin
On Fri, May 6, 2011 at 1:50 PM, Ton Voon <[email protected]> wrote:
> Hi!
>
> Is it possible to have a has_many relationship where the LEFT JOIN ON
> relationship contains a parameter? For instance, something like in User.pm:
>
> __PACKAGE__->has_many( "useraccounts", "UserAccounts", { "foreign.userid"
> => "self.id", "foreign.accountid" => $value }, { join_type => "left" } );
>
> Where $value can be specified as part of the search for the ON condition.
>
> Is this possible?
>
> Ton
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/[email protected]
>
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]