Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-10 Thread Mike Raynham
On 11/11/10 07:38, Alexander Hartmaier wrote: See below. -- Best regards, Alex [ snip ] >> # Create a search. >> my $date_ranges = $rs->search({}); > > No need to call search which returns a resultset which you already > have. Hi, Thanks - I corrected that in an earlier post. It was a stupi

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-10 Thread Alexander Hartmaier
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->s

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-10 Thread Alexander Hartmaier
Note that by swapping column and value you will lose the advantage of bind which makes sql injection impossible. -- Best regards, Alex On Wed, 2010-11-10 at 06:34 +0100, Mike Raynham wrote: > On 09/11/10 22:26, Peter Rabbitson wrote: > > > > -nest...? what...? > > > > I still don't understand ho

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Mike Raynham
On 09/11/10 22:26, Peter Rabbitson wrote: -nest...? what...? I still don't understand how this is different from anything you've showed us in the thread so far. You said you want to do: WHERE ($start_date >= start_date AND $start_date <= end_date) OR ($end_date >= start_date AND $end_date <= e

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Peter Rabbitson
Mike Raynham wrote: On 09/11/10 16:14, Peter Rabbitson wrote: Mike Raynham wrote: I have tested it, and it returns the results I would expect. I think the confusion comes from the order in which the WHERE expression is produced. If I were to write the SQL myself, without DBIx, I'd probably I

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Mike Raynham
On 09/11/10 16:14, Peter Rabbitson wrote: Mike Raynham wrote: I have tested it, and it returns the results I would expect. I think the confusion comes from the order in which the WHERE expression is produced. If I were to write the SQL myself, without DBIx, I'd probably It's DBIx::Class. DBIx

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Peter Rabbitson
Mike Raynham wrote: I have tested it, and it returns the results I would expect. I think the confusion comes from the order in which the WHERE expression is produced. If I were to write the SQL myself, without DBIx, I'd probably It's DBIx::Class. DBIx is a namespace with hundreds of modul

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Mike Raynham
On 09/11/10 15:02, Peter Rabbitson wrote: Ronald J Kimball wrote: On Tue, Nov 9, 2010 at 8:36 AM, Mike Raynham mailto:catal...@mikeraynham.co.uk>> wrote: I have created a query which determines if a given date range exists within date ranges stored in the database: ### # SELECT * FROM my_tab

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Ronald J Kimball
On Tue, Nov 9, 2010 at 8:36 AM, Mike Raynham wrote: > > I have created a query which determines if a given date range exists within > date ranges stored in the database: > > ### > > # SELECT * FROM my_table WHERE > # (start_date <= $start_date AND end_date >= $start_date) OR > # (start_date <= $en

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Steve
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 mus

[Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Mike Raynham
Hi, I am probably missing something obvious here, but have been unable to find a clean solution to the following problem, and I'm hoping that your expert knowledge will come to the rescue. I have created a query which determines if a given date range exists within date ranges stored in the d

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Mike Raynham
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 o

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Peter Rabbitson
Ronald J Kimball wrote: On Tue, Nov 9, 2010 at 8:36 AM, Mike Raynham > wrote: I have created a query which determines if a given date range exists within date ranges stored in the database: ### # SELECT * FROM my_table WHERE # (start_date