[Dbix-class] How to do 'find' for comibinational primary key

John Napiorkowski jjn1056 at yahoo.com
Mon Oct 1 19:49:03 GMT 2007


--- Ramprabhu Kaliaperumal
<ramprabhu.kaliaperumal at oracle.com> wrote:

> Hi
> 
> I have a table with combinational primary key like
> below
> 
> __PACKAGE__->set_primary_key(qw(sent_at sender
> receiver subject message));
> 
> 
> When I do find I am not getting the row object.
> Following is my code...
> 
>     my $hash = {
>       sent_at     => $sent_at,
>       sender      => $sender,
>       receiver    => $receiver,
>       subject     => $subject,
>       message     => $message
>     };
> 
>     my $log =
>
$schema->resultset('NotificationLog')->single($hash);
> 
> Please let me know how to do find for combinational
> primary key?
> 
> Thanks & Regards
> -Ran

I also have tables with multi column PKs and multi
column uniques and haven't had any trouble with DBIC's
standard searching and finding methods.  It even
correctly inflates relationships with multi column
PKs.  So just use ..->find({key1=>$val1,key2=>$val2})
and that should give you a result.  Or is you want the
resultset via a relationship, just use the
relationship  accessor and it will do the right thing.

--john


      ____________________________________________________________________________________
Check out the hottest 2008 models today at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html



More information about the DBIx-Class mailing list