[Dbix-class] Providing extra limitations to query

Will Crawford billcrawford1970 at gmail.com
Tue Jan 10 13:49:06 GMT 2012


$rs->search( \%implicit_params )->search( ... stuff passed into your
function ...);

I've occasionally done this more overtly by having a ->with_filter_X
method on the result set, and called it like
$foo_rs->with_melitta->search( \%user_supplied_params ) ... good
examples would be where you have, say, a "deleted" flag column and you
must only search in non-"deleted" records.

On 10 January 2012 13:03, Dmitry Belyavsky <beldmit at gmail.com> wrote:
> Greetings!
>
> I have a function similar to
>
> my $account_id = shift;
> my $query_params = shift;
>
> my $rs = $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 = {-and => [$query_params, {restrictions} ]}
> my $rs = $schema->result("Table")->search($query_params);
>
> How can I do it in case of the array ref passed as original params?
> Thank you!
>
> --
> SY, Dmitry Belyavsky
>
> _______________________________________________
> 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/dbix-class@lists.scsys.co.uk



More information about the DBIx-Class mailing list