[CDBI] Re: select lower(thing) from...
oj at defuturo.co.uk
Thu Jan 18 16:36:45 GMT 2007
Edward J. Sabol wrote:
>> I've not seen anything to suggest this can be done in CDBI, but I
>> thought I'd give it a shot anyway.
> Everything that you can do with SQL can be done with CDBI.
Well, yes, but sometimes you have to revert to writing the SQL yourself
to do it, which I don't really count as 'being done with CDBI'.
> You could use set_sql(), but I would probably use add_constructor(), since
> it's a little more succinct. Put the following in your CDBI class for the
> table that you want to do case-insensitive searches:
> MyCDBIClass->add_constructor(isearch_column => "lower(column) = ?");
> Then, in the code, you do
> my @results = MyCDBIClass->isearch_column(lc($column_value));
> You can also use Class::DBI::AbstractSearch, like this:
> my @results = MyCDBIClass->search_where(
> column => [ 'lower(column) = ?', lc($column_value) ]
> or something like that.
> Hope this helps,
That does help, a lot, thanks. I wasn't aware that I'd be able to use an
operator like that in a where clause with AbstractSearch, and that's
probably the method I will use.
Thanks again for the help.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.digitalcraftsmen.net/pipermail/classdbi/attachments/20070118/9969b0b3/signature.pgp
More information about the ClassDBI