NAME
Rose::DBx::Object::MoreHelpers - more mixin helpers for RDBO
SYNOPSIS
package MyRDBO;
use base qw( Rose::DB::Object );
use Rose::DBx::Object::MoreHelpers;
DESCRIPTION
In the tradition of Rose::DB::Object::Helpers, more importable methods.
This class inherits from Rose::Object::MixIn. See the Rose::Object::MixIn documentation for a full explanation of how to import methods from this class. The helper methods themselves are described below.
METHODS
MoreHelpers changes the default relationship method makers to include:
find
get_set_on_save
add_on_save
count
iterator
primary_key_uri_escaped
Returns the primary key value, URI-escaped. If there are multiple columns comprising the primary key, they are joined into a single string.
If there are no values set for any of the column(s) comprising the primary key, returns 0.
Otherwise, returns all column values joined with ;;
as per CatalystX::CRUD::Controller API.
primary_key_value
Returns the value of the primary key column(s). If the value is comprised of multiple column values, the return value will be an array ref of values.
flatten
Returns the serialized object and its immediately related objects.
TODO this method does not yet support column aliases.
exists( [ @params ] )
Returns true if the object exists in the database, false otherwise.
May be called as class or object method.
This method uses the Rose::DB::Object::Manager class to check the database based on non-unique column(s). Call it like you would load_speculative() but when you do not have a unique combination of columns (which all the load* methods require).
When called as object method, if @params is omitted, the current column values of the object are used.
Example:
# 'title' has no unique constraints on it
my $object = Object->new(title => 'Foo');
$object->save unless $object->exists;
NOTE: Using exists() as a way of enforcing data integrity is far inferior to actually placing a constraint on a table in the database. However, for things like testing and development data, it can be a useful utility method.
has_related( relationship_name )
Returns the number of related objects defined by the relationship_name accessor.
Just a wrapper around the count RDBO method type.
has_related_pages( relationship_name, page_size )
Returns the number of "pages" given page_size for the count of related object for relationship_name. Useful for creating pagers.
fetch_all
Shortcut for the Manager method get_objects().
fetch_all_iterator
Shortcut for the Manager method get_objects_iterator().
column_is_boolean( column_name )
Returns true if the column type for column_name is 'boolean'.
AUTHOR
Peter Karman, <karman at cpan.org>
BUGS
Please report any bugs or feature requests to bug-rose-dbx-object-morehelpers at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Rose-DBx-Object-MoreHelpers. 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 Rose::DBx::Object::MoreHelpers
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Rose-DBx-Object-MoreHelpers
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2008 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.