[Dbix-class] Chained resultsets and WHERE operators

Alexander Hartmaier alexander.hartmaier at t-systems.at
Thu Nov 11 07:38:54 GMT 2010


See below.
--
Best regards, Alex


On Tue, 2010-11-09 at 14:54 +0100, Mike Raynham wrote:
> On 09/11/10 13:49, Steve wrote:
> > It appears that you are *not* chaining these resultsets...
> >
> > If you first do...
> > # Narrow the search down if the start date is supplied.
> > $date_ranges = $rs->search({
> > start_date => { '<=', $start_date },
> > end_date => { '>=', $start_date },
> > }) if $start_date;
> >
> > then in order to 'chain' you must...
> >
> > $date_ranges = $date_ranges->search({...
> >
> > You overwrote your resultset when you...
> >
> > # Narrow the search down if the end date is supplied.
> > $date_ranges = $rs->search({
> > start_date => { '<=', $end_date },
> > end_date => { '>=', $end_date },
> > }) if $end_date;
>
> Sorry, that was my mistake when reducing my original code down for the
> email.  You are right - it should have read:
>
> ###
>
> # Create a search.
> my $date_ranges = $rs->search({});

No need to call search which returns a resultset which you already have.

>
> # Narrow the search down if the start date is supplied.
> $date_ranges = $date_ranges->search({
>      start_date => { '<=', $start_date },
>      end_date   => { '>=', $start_date },
> }) if $start_date;
>
> # Narrow the search down if the end date is supplied.
> $date_ranges = $date_ranges->search({
>      start_date => { '<=', $end_date },
>      end_date   => { '>=', $end_date },
> }) if $end_date;
>
> ###
>
> _______________________________________________
> 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


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the DBIx-Class mailing list