[Rt-devel] DBIx::SearchBuilder - Limit by multiple fields using OR clause

Miroslav Laus laus at karneval.cz
Thu Sep 23 03:11:09 EDT 2004


Thanks Jesste, it works like a charm.

Miroslav

On 23. Sep v 02:59, Jesse Vincent wrote:
> 
> 
> 
> On Thu, Sep 23, 2004 at 08:53:41AM +0200, Miroslav Laus wrote:
> > Hello,
> > 
> > I found DBIx::Searchbuilder is using the ENTRYAGGREGATOR 'OR' only when
> > limiting to the same field multiple times. Let's say if I want to Limit the
> > Users table by Name or RealName a can't make it to use OR clause. It still uses
> > AND and it seems to me it cannot be changed without changing the
> > DBIx::SearchBuilder.
> 
> use SUBCLAUSE => 'mysubclause' in your Limit statements to get both
> entries into the same subclause.
> 	
> 	-jesse
> 
> > 
> > For example this code:
> > 
> >   my $UsersObj = new RT::Users($self->CurrentUser);
> >   $UsersObj->Limit(
> >   	FIELD => 'Name',
> >   	VALUE => 'something',
> >   	OPERATOR => 'LIKE'
> >   );
> >   
> >   $UsersObj->Limit(
> >   	FIELD => 'RealName',
> >   	VALUE => 'something',
> >   	OPERATOR => 'LIKE',
> >   	ENTRYAGGREGATOR => 'OR'
> >   );
> > 
> > produces this query:
> > 
> > SELECT * FROM Users main WHERE ( ((main.Disabled = 0)) AND ((main.Name LIKE
> > '%something%')) AND ((main.RealName LIKE '%SOMETHING%')) )
> > 
> > but I want it this way:
> > 
> > SELECT * FROM Users main WHERE ( ((main.Disabled = 0)) AND ((main.Name LIKE
> > '%something%') OR (main.RealName LIKE '%SOMETHING%')) )
> > 
> > Can this be achieved via some documented way?
> > 
> > -- 
> > Greets,
> > 
> > Miroslav Laus, DiS
> > Senior technician, Operations Management Center
> > --
> > Karneval Media s.r.o.
> > U svobodarny 5/1500
> > 190 00 Praha 9
> > Czech republic
> > tel: +420 2 8408 5354
> > fax: +420 2 8408 5817
> > mob: +420 724 608 011
> > e-mail: laus at karneval.cz
> > http://www.karneval.cz
> > 
> > _______________________________________________
> > Rt-devel mailing list
> > Rt-devel at lists.bestpractical.com
> > http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
> > 
> 
> -- 


More information about the Rt-devel mailing list