Class::DBI::AbstractSearch - Abstract Class::DBI's SQL with SQL::Abstract
package CD::Music; use Class::DBI::AbstractSearch; package main; my @music = CD::Music->search_where( artist => [ 'Ozzy', 'Kelly' ], status => { '!=', 'outdated' }, ); my @misc = CD::Music->search_where( { artist => [ 'Ozzy', 'Kelly' ], status => { '!=', 'outdated' } }, { order_by => "reldate DESC" });
Class::DBI::AbstractSearch is a Class::DBI plugin to glue SQL::Abstract into Class::DBI.
Using this module adds following methods into your data class.
$class->search_where(%where);
Takes a hash to specify WHERE clause. See SQL::Abstract for hash options.
$class->search_where(\%where,\%attrs);
Takes hash reference to specify WHERE clause. See SQL::Abstract for hash options. Takes a hash reference to specify additional query attributes. Class::DBI::AbstractSearch uses these attributes:
order_by
Array reference of fields that will be used to order the results of your query.
Any other attributes are passed to the SQL::Abstract constructor, and can be used to control how queries are created. For example, to use 'AND' instead of 'OR' by default, use:
$clsas->search_where(\%where, { logic => 'AND' });
Tatsuhiko Miyagawa <miyagawa@bulknews.net> with some help from cdbi-talk mailing list, especially:
Tim Bunce Simon Wilcox Tony Bowden
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Class::DBI, SQL::Abstract
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install Class::DBI::AbstractSearch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::DBI::AbstractSearch
CPAN shell
perl -MCPAN -e shell install Class::DBI::AbstractSearch
For more information on module installation, please visit the detailed CPAN module installation guide.