[CDBI] Re: Search by "or".

"Edward J. Sabol" <sabol-2oVx0MVsMgiP/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
> For a given column Is it possible to search for more than one value?
> for instance how would I search for an employee with the first name
> of either "William" or "Bill"?
>
> # Search for "William".
> @employees = Comp::Employee->search( first_name => 'William' );
>
> is "retrieve_from_sql" the only way to do this?

Well, you could combine the results fo two searches:

@employees = Comp::Employee->search( first_name => 'William' );
push @employees, Comp::Employee->search( first_name => 'Bill' );

In my experience, that could actually be faster with some databases!

Or you could use CDBI::AbstractSearch:

http://search.cpan.org/~miyagawa/Class-DBI-AbstractSearch/lib/Class/DBI/AbstractSearch.pm

Hope this helps,
Ed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.