On Wed, Sep 24, 2008 at 12:15:08AM -0700, theshz wrote:
> Hi, I'm new to Catalyst, just went through the Tutorial, everything worked 
> fine. But for my reporting application (part of a bigger application where 
> CRUD will be more often), I need to run some complicated querries. I did find 
> the "Arbitray SQL" article in DBIx's FAQ, but I don't even know how to get to 
> DBIx, if that's the right way, more specifically, 
> 
> Is it possible to get the database handle and run SQL directly as in DBI? I 
> read that from Schema I can get its storage, which is the db handle. But from 
> a Controller, how do I get the schema object, or the db handle? If the DBIx 
> is the correct way to go (which seems a lengthy way to "just" run a query), 
> do I do $c->model('Some::Model')->resultset....?

If you aren't planning to use DBIx::Class at all, I'd recommend
Catalyst::Model::DBI

If you're using DBIx::Class, I'd recommend abstracting the query away behind
a resultset method - something like

sub my_custom_query {
  my ($self, @args) = @_;
  my $code = sub {
    my $dbh = shift;
    <run query here>
  };
  $self->result_source->schema->storage->dbh_do($code);
}

If this example isn't sufficient, you should be asking on the dbix-class
list, not here.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to