Class::DBI::AbstractSearch3pm
Abstract class::dbi's sql with sql::abstract::limit
Usage
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",limit_dialect => 'LimitOffset',limit => 1offset => 2 });
Overview
Class::DBI::AbstractSearch is a Class::DBI plugin to glue SQL::Abstract::Limit into Class::DBI.
Methods
Using this module adds following methods into your data class.
- search_where
-
$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_byArray reference of fields that will be used to order the results of your query.
- •
-
limit_dialectScalar, DBI handle, object class, etc. that describes the syntax model for a LIMIT/OFFSET SQL clause. Please see SQL::Abstract::Limit for more information.
- •
-
limitScalar value that will be used for LIMIT argument in a query.
- •
-
offsetScalar value that will be used for OFFSET argument in a query.
Any other attributes are passed to the SQL::Abstract::Limit constructor, and can be used to control how queries are created. For example, to use 'AND' instead of 'OR' by default, use:
$class->search_where(\%where, { logic => 'AND' });
Releases
11 releases since Debian 3.1 (Sarge); the text changed 4 times.