The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Catalyst::Model::RDBO - base class for Rose::DB::Object model

SYNOPSIS

 package MyApp::Model::Foo;
 use base qw( Catalyst::Model::RDBO );
 
 __PACKAGE__->config(name      => 'My::Rose::Class',
                    load_with => ['foo']);

 # assumes you also have a My::Rose::Class::Manager class

 1;
 
 # then in your controller
 
 my $object = $c->model('Foo')->fetch(id=>1);
 
 

DESCRIPTION

Catalyst Model base class.

METHODS

new

name

Returns the name value from config().

manager

Returns the name value from config() with ::Manager appended. This assumes the namespace convention of Rose::DB::Object::Manager, so if you do not have a Manager class defined for you RDBO-subclass, you should either create one in the expected namespace, or override this method to return the actual Manager class name.

fetch( @params )

If present, @params is passed directly to name()'s new() method, and is expected to be an array of key/value pairs. In addition, the object's load() method is called with the speculative flag.

If not present, the new() object is simply returned.

All the methods called within fetch() are wrapped in an eval() and sanity checked afterwards. If there are any errors, the context's error() method is set with the error message.

Example:

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

fetch_all( @params )

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

You can also use all().

search( @params )

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

count( @params )

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

iterator( @params )

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

AUTHOR

Peter Karman

Thanks to Atomic Learning, Inc for sponsoring the development of this module.

LICENSE

This library is free software. You may redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Rose::DB::Object