[Dbix-class] Providing extra limitations to query

will trillich will.trillich at serensoft.com
Tue Jan 10 15:16:20 GMT 2012


On Tue, Jan 10, 2012 at 7:56 AM, Rob Kinyon <rob.kinyon at gmail.com> wrote:

> On Tue, Jan 10, 2012 at 08:49, Will Crawford <billcrawford1970 at gmail.com>
> wrote:
> > $rs->search( \%implicit_params )->search( ... stuff passed into your
> > function ...);
>


> > On 10 January 2012 13:03, Dmitry Belyavsky <beldmit at gmail.com> wrote:
> >> Greetings!
> >>
> >> I have a function similar to
> >>
> >> my $account_id =3D shift;
> >> my $query_params =3D shift;
> >>
> >> my $rs =3D $schema->result("Table")->search($query_params);
> >>
> >> I want to provide account-related access restrictions implicitly so I
> >> need to modify the $query_params variable. There are no problems when
> >> the $query_params is a hash reference, the code looks like
> >>
> >> my $params =3D {-and =3D> [$query_params, {restrictions} ]}
> >> my $rs =3D $schema->result("Table")->search($query_params);
> >>
> >> How can I do it in case of the array ref passed as original params?
> >> Thank you!
>
> The key to remember here is that ->search() doesn't actually search
> anything - it's a constructor that builds a resultset from another
> resultset. A resultset is not a search. It's all the information
> necessary to build the various clauses that would go into a search.
>



> As Rob says, you don't have to munge your argument list in place, you can
keep your code as is, and then just add one more call -- see ideas here:
http://www.gossamer-threads.com/lists/catalyst/users/29449


-- =

"We act as though comfort and luxury were the chief requirements of life,
when all that we need to make us happy is something to be enthusiastic
about." -- Albert Einstein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120110/a71=
c7ac0/attachment.htm


More information about the DBIx-Class mailing list