[Dbix-class] partial sth compatibility in ResultSet?

Matt S Trout dbix-class at trout.me.uk
Wed Apr 26 19:17:17 CEST 2006


Brandon Black wrote:
> I have some queries in my application that cannot (yet) be handled
> efficiently (or in some cases at all) by DBIC, so I still have to use
> raw DBI queries here and there where neccesary.  I've run into what's
> becoming an increasingly common idiom in my particular case, where I
> end up with code like this in a Catalyst action:
> 
> --------------------------------
> sub some_action : Local {
>    ...
> 
>    my $results;
>    if(something) {
>        $results = $c->model('Foo::Bar')->search(....)->.....
>    }
>    elsif(something_else) {
>        $results = $dbh->prepare(.............);
>        $results->execute(......);
>    }
>    elsif .....
> 
>    while( [iterate $results] ) {
          if (rs) { $result = $results->next }
          else { $result = MyApp::Model::Foo::Bar->inflate_result(
                   $c->model('Foo::Bar')->result_source,
                   $results->fetchrow_hashref);
               }

>        # do things with row;
>    }
> }

How about that?

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list