[CDBI] Re: select lower(thing) from...
Oliver Jeeves <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
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, > Ed 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. -Oli _______________________________________________ ClassDBI mailing list ClassDBI-Ra3b/[email protected] http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFFr6IiSbWXajvTQ+URAih/AJwM1hAp1OLeopKVclc2R12jKzL10gCfQYIB KEeaFv2mramwULt7Us8GSAM= =6414 -----END PGP SIGNATURE-----