NAME

CatalystX::CRUD::Model::RDBO - Rose::DB::Object CRUD

SYNOPSIS

package MyApp::Model::Foo;
use base qw( CatalystX::CRUD::Model::RDBO );
__PACKAGE__->config( 
           name            => 'My::RDBO::Foo', 
           manager         => 'My::RDBO::Foo::Manager',
           load_with       => [qw( bar )],
           page_size       => 50,
           );
1;

DESCRIPTION

CatalystX::CRUD::Model::RDBO is a CatalystX::CRUD implementation for Rose::DB::Object.

CONFIGURATION

The config options can be set as in the SYNOPSIS example.

METHODS

name

The name of the Rose::DB::Object-based class that the model represents. Accessible via name() or config->{name}.

manager

If manager is not defined in config(), the Xsetup() method will attempt to load a class named with the name value from config() with ::Manager appended. This assumes the namespace convention of Rose::DB::Object::Manager.

If there is no such module in your @INC path, then the fall-back default is Rose::DB::Object::Manager.

Xsetup

Implements the required Xsetup() method. Instatiates the model's name() and manager() values based on config().

new_object( @param )

Returns a CatalystX::CRUD::Object::RDBO object.

fetch( @params )

If present, @params is passed directly to name()'s new() method, and is expected to be an array of key/value pairs. Then the load() method is called on the resulting object.

If @params are not present, the new() object is simply returned, which is equivalent to calling new_object().

All the methods called within fetch() are wrapped in an eval() and sanity checked afterwards. If there are any errors, throw_error() is called.

Example:

my $foo = $c->model('Foo')->fetch( id => 1234 );
if (@{ $c->error })
{
   # do something to deal with the error
}

NOTE: If the object's presence in the database is questionable, your controller code may want to use new_object() and then call load_speculative() yourself. Example:

my $foo = $c->model('Foo')->new_object( id => 1234 );
$foo->load_speculative;
if ($foo->not_found)
{
  # do something
}

search( @params )

@params is passed directly to the Manager get_objects() method. See the Rose::DB::Object::Manager documentation.

Returns an array or array ref (based on wantarray) of CatalystX::CRUD::Object::RDBO objects.

count( @params )

@params is passed directly to the Manager get_objects_count() method. See the Rose::DB::Object::Manager documentation.

Returns an integer.

iterator( @params )

@params is passed directly to the Manager get_objects_iterator() method. See the Rose::DB::Object::Manager documentation.

Returns a CatalystX::CRUD::Iterator object whose next() method will return a CatalystX::CRUD::Object::RDBO object.

make_query( field_names )

Implement a RDBO-specific query factory based on request parameters. Return value can be passed directly to search(), iterator() or count() as documented in the CatalystX::CRUD::Model API.

See CatalystX::CRUD::Model::Utils::make_sql_query() for API details.

treat_like_int

Returns hash ref of all column names that return type =~ m/^date(time)$/. This is so that wildcard searches for date and datetime-based columns will get proper SQL rendering.

AUTHOR

Peter Karman, <karman at cpan.org>

BUGS

Please report any bugs or feature requests to bug-catalystx-crud-model-rdbo at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-CRUD-Model-RDBO. 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::Model::RDBO

You can also look for information at:

ACKNOWLEDGEMENTS

This module is based on Catalyst::Model::RDBO by the same author.

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.