Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: SQL function from DBIC

by davidrw (Prior)
on Dec 07, 2008 at 15:30 UTC ( #728726=note: print w/ replies, xml ) Need Help??


in reply to SQL function from DBIC

See the "Arbitrary SQL through a custom ResultSource" section in DBIx::Class::Manual::Cookbook

Also, I think (untested, but appears so from grepping distro) that you can do:

my $dbh = $myobj->db_Main; use Data::Dumper; print Dumper $dbh->selectall_arrayref( 'select enum_range(typename); +', {Slice=>{}}, () );


Comment on Re: SQL function from DBIC
Download Code
Replies are listed 'Best First'.
Re^2: SQL function from DBIC
by jasonk (Parson) on Dec 07, 2008 at 23:22 UTC

    If you are going to dig in and do something with a database handle directly, the recommended way is:

    use Data::Dumper; $schema->storage->dbh_do( sub { my ( $storage, $dbh ) = @_; print Dumper $dbh->selectall_arrayref( 'select enum_range(typename);', { slice => {} } ); } );

    The dbh_do method (documented in DBIx::Class::Storage::DBI) gives you the benefit of things like automatic reconnection to the database if your connection has timed out or the server has been restarted.

    Also, db_Main is from Class::DBI, not DBIx::Class, although there is a CDBICompat component that will make the latter work mostly like the former (though in the long run you will be better off by just learning the DBIx::Class way, rather than using CDBICompat).


    www.jasonkohles.com
    We're not surrounded, we're in a target-rich environment!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://728726]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2015-08-01 02:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls