NAME

CatalystX::CRUD::Model::Utils - helpful methods for your CRUD Model class

SYNOPSIS

package MyApp::Model::Foo;
use base qw( 
   CatalystX::CRUD::Model
   CatalystX::CRUD::Model::Utils
 );
# ... 
1;

DESCRIPTION

CatalystX::CRUD::Model::Utils provides helpful not non-essential methods for CRUD Model implementations. Stick it in your @ISA to help reduce the amount of code you have to write yourself.

METHODS

use_ilike( boolean )

Convenience accessor to flag requests in params_to_sql_query() to use ILIKE instead of LIKE SQL command.

ne_sign( string )

What string to use for 'not equal' in params_to_sql_query(). Defaults to '!='.

make_sql_query( [ field_names ] )

Returns a hashref suitable for passing to a SQL-oriented model.

field_names should be an array of valid form field names. If false or missing, will call $c->controller->field_names().

The following reserved request param names are implemented:

_order

Sort order. Should be a SQL-friendly string parse-able by Sort::SQL.

_sort

Instead of _order, can pass one column name to sort by.

_dir

With _sort, pass the direction in which to sort.

_page_size

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.

_page

What page the current request is coming from. Used to set the offset value in the query. Defaults to 1.

_offset

Pass explicit row to offset from in query. If not present, deduced from _page and _page_size.

_no_page

Ignore _page_size, _page and _offset and do not return a limit or offset value.

sql_query_as_string( params_to_sql_query->{query} )

Returns the request params as a SQL WHERE string.

params_to_sql_query( field_names )

Convert request->params into a SQL-oriented query.

Returns a hashref with two key/value pairs:

sql

Arrayref of ORM-friendly SQL constructs.

query

Hashref of column_name => raw_values_as_arrayref.

Called internally by make_sql_query().

AUTHOR

Peter Karman, <perl at peknet.com>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc CatalystX::CRUD

You can also look for information at:

COPYRIGHT & LICENSE

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.