On 10/24/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> On 10/25/07 12:45 AM, Arshavir Grigorian wrote:
> > In my class definition, I have
> >
> > primary_key_columns => [ 'pk' ],
> > unique_key => [ 'pk', 'col2' ],
> >
> > Since, I am accessing the data more often using the 2 column match,
> > does it make sense to trick Rose into thinking that my primary key is
> > really a compound key (pk, col2), then just use
> > get_() method to get the row matching pk only?
>
> You can force load() to use a specific key by passing the use_key parameter.
>
> http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object.pm#use_key
>
> That said, if you have the value of pk, why would you ever want to load
> using the unique key?
>
> -John
>

Thanks. I guess I am not sure how the unique keys are named,

my $file = My::File->new(id => 1, usr_id => 2);
if ($file->load( speculative => 1, use_key => [ 'id', 'usr_id' ] )) {
...
gives:

No unique key named 'ARRAY(0x9e5d918)' is defined in My::File

I need to use the unique key for security reasons to prevent users
from embedding an arbitrary id in the url and accessing other user's
data. Usr_id is maintained via sessions and the user has no way of
tampering with it.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to