CatalystX::CRUD::Model::Utils - helpful methods for your CRUD Model class
package MyApp::Model::Foo; use base qw( CatalystX::CRUD::Model CatalystX::CRUD::Model::Utils ); # ... 1;
CatalystX::CRUD::Model::Utils provides helpful, non-essential methods for CRUD Model implementations. Stick it in your @ISA to help reduce the amount of code you have to write yourself.
Convenience accessor to flag requests in params_to_sql_query() to use ILIKE instead of LIKE SQL command.
What string to use for 'not equal' in params_to_sql_query(). Defaults to '!='.
Should return a hashref of column names to treat as integers instead of text strings when parsing wildcard request params. Example might be all date/timestamp columns.
Returns a hashref suitable for passing to a SQL-oriented model.
field_names should be an array of valid column names. If false or missing, will call $c->controller->field_names().
The following reserved request param names are implemented:
Sort order. Should be a SQL-friendly string parse-able by Sort::SQL.
Instead of cxc-order, can pass one column name to sort by.
With cxc-sort, pass the direction in which to sort.
For the Data::Pageset pager object. Defaults to page_size(). An upper limit of 200 is implemented by default to reduce the risk of a user [unwittingly] creating a denial of service situation.
What page the current request is coming from. Used to set the offset value in the query. Defaults to 1.
1
Pass explicit row to offset from in query. If not present, deduced from cxc-page and cxc-page_size.
Ignore cxc-page_size, cxc-page and cxc-offset and do not return a limit or offset value.
If set to OR then the query columns will be marked as OR'd together, rather than AND'd together (the default).
OR
The query string to use. This overrides any param values set for field names.
Which field names to set as 'default_column' in the Search::QueryParser::SQL parser object. The default is all field_names. NOTE this param is only checked if cxc-query has a value.
cxc-query
If set to a true value triggers the 'fuzzify' feature in Search::QueryParser::SQL.
If set to a true value, overrides cxc-fuzzy and triggers the 'fuzzify2' feature in Search::QueryParser::SQL.
Convert request->params into a SQL-oriented query.
Returns a hashref with three key/value pairs:
Arrayref of ORM-friendly SQL constructs.
Hashref of column_name => raw_values_as_arrayref.
The Search::QueryParser::SQL::Query object used to generate sql.
sql
Called internally by make_sql_query().
Returns a Data::Pageset object using total, either the _page_size param or the value of page_size(), and the _page param or 1.
_page_size
_page
If the _no_page request param is true, will return undef. NOTE: Model authors should check (and respect) the _no_page param when constructing queries.
_no_page
Peter Karman, <perl at peknet.com>
<perl at peknet.com>
Please report any bugs or feature requests to bug-catalystx-crud at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-CRUD. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-catalystx-crud at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc CatalystX::CRUD
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/CatalystX-CRUD
CPAN Ratings
http://cpanratings.perl.org/d/CatalystX-CRUD
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=CatalystX-CRUD
Search CPAN
http://search.cpan.org/dist/CatalystX-CRUD
Copyright 2007 Peter Karman, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install CatalystX::CRUD, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::CRUD
CPAN shell
perl -MCPAN -e shell install CatalystX::CRUD
For more information on module installation, please visit the detailed CPAN module installation guide.