in Collection.pm, i have sub count_assets { my $self = shift; return CollectionAsset::Manager->get_collection_assets_count( require_objects => ['asset'], query => [ collection_id => $self- >collection_id, @_ ], ); }
sub count_assets_published { my $self = shift; return $self->count_assets('asset.pubstatus' => 'published', @_); } and later: my $count = $collection->count_assets_published( [ \'t2.pubdate >= NOW() - INTERVAL ? DAY' => $num_days ] # t2 ~> asset ); i can't refer to 'asset.pubdate' in this query param, because RDBOM insists i use a scalar-ref here, and wisely avoids doing substitutions when handed a scalar-ref, and mysql won't let me refer to the table by its real name once it has been aliased.. since the generated query aliases asset as t2, i have to use t2 here, though not elsewhere. needless to day, it's a little confusing, especially to future-maintenance-programmer. any advice? another thing i am struggling with a bit is allowing such helper methods to modify both the query and manager_args. in the above example, require_objects=>['asset'] isn't required in the basic case where it exists, but is there because methods like count_assets_published need to refer to the assets.. seems common enough, so maybe there is already a convenient way to merge manager args in this case? here is a bit of ugliness that hints at what i am after: sub count_assets { my $self = shift; my ($manager_args, $query_args) = _separate_manager_query_args(@_); return Plex::RDBO::CollectionAsset::Manager- >get_collection_assets_count( @$manager_args, query => [ collection_id => $self->collection_id, @ $query_args ], ); } sub count_assets_published { my $self = shift; my ($manager_args, $query_args) = _separate_manager_query_args(@_); return $self->count_assets( require_objects => ['asset'], @$manager_args, query => [ 'asset.pubstatus' => 'published', @ $query_args ] ); } sub _separate_manager_query_args { my @manager_args = @_; my @query_args; foreach my $i (0..$#manager_args) { if ($manager_args[$i] eq 'query') { @query_args = @{ (splice @manager_args, $i, 2)[1] }; last; } } return ([EMAIL PROTECTED], [EMAIL PROTECTED]); } any advice? ;) ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object