On 6/1/06, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
i did a data::dumper to explore the structure a bit, and there are a
bunch of rosedb internal fields in a db object - i'm wondering if
there's a quick way to just extract the field key/value pairs so i
can populate something else with a rose resultset
ie
foreach my $col ( $roseObj->columns ){
$newObj{ $col }= $roseObj->$col ;
}
That's bad code because it assumes that the column accessor name is
the same as the column name, which is not always the case. You also
have to decide whether you want a hash of accessor-name/value pairs:
foreach my $method ($o->meta->column_accessor_method_names)
{
$data{$method} = $o->method();
}
or a hash of column-name/value pairs:
foreach my $column ($o->meta->columns)
{
my $method = $column->accessor_method_name;
$data{$column->name} = $o->$method();
}
But what it looks like you're trying to do is clone an object. If
that's the case, check out the clone() and clone_and_reset() helper
methods in Rose::DB::Object::Helpers.
http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Helpers.pm
-John
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object