On Tue, May 22, 2007 at 12:16:20PM -0400, John Goulah wrote:
> >So I have a function like:
> >>
> >> sub get_some_data : ResultSet {
> >>    my ($self) = @_;
> >>    my $dbh = $self->result_source->schema->storage->dbh;
> >>
> >>    my $sth = $dbh->prepare("select * from sometable");
> >>    $sth->execute();
> >>
> >>    ##### this doesn't work, how do I  use this method?
> >>    return $self->sth_to_objects($sth);
> >
> >You don't. That's a method on a resultset object, and the CDBICompat stuff
> >won't show up there - which is a good thing, since sth_to_objects it
> >pretty
> >horrible since it's a COMPATIBILITY LAYER feature, not a DBIC feature.
> >
> >How about
> >
> >    my @results;
> >    while (my $hr = $sth->fetchrow_hashref) {
> >      push(@results,
> >        $self->result_class->inflate_result(
> >          $self->result_source, $hr, {}
> >        )
> >      );
> >    }
> >    return @results;
> >
> >?
> 
> 
> 
> Yes thats exactly what I was looking for, thank you.  So if I were to want
> this method shared on all my resultset objects, would you suggest creating
> an object that inherits from the ResultSetManager (or somethign similar) and
> putting it in there?

A class that uses base DBIx::Class::ResultSet and then just do

__PACKAGE__->resultset_class('My::ResultSet::Class');

in any table class that needs it. ResultSetManager is just a convenience
syntax to that, and causes enough problems in more complex cases there's
serious consideration being given to deprecating it in favour of saner
syntax.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to