Catalyst::Model::RDBO(3)

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',
        manager   => 'My::Rose::Class::Manager',
        load_with => ['bar']
        );

 1;

 # then in your controller

 my $object = $c->model('Foo')->fetch(id=>1);

DESCRIPTION
Catalyst Model base class.

METHODS

  new
Initializes the Model. This method is called by the Catalyst setup() method.

See manager() method to understand how that class is handled.

  name
Returns the "name" value from config().

  manager
Returns the "manager" value from config().

If "manager" is not defined in config(), the new() 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.

  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

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

Thanks to Bill Moseley for API suggestions.

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