Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

[DBIx::Class] Can I extract $dbhandle from schema?

by dreel (Sexton)
on Aug 21, 2007 at 05:39 UTC ( [id://634006]=perlquestion: print w/replies, xml ) Need Help??

dreel has asked for the wisdom of the Perl Monks concerning the following question:

I can clone connection, but I don't understand how it works and can i extract $dbh from this?

Replies are listed 'Best First'.
Re: [DBIx::Class] Can I extract $dbhandle from schema?
by LTjake (Prior) on Aug 21, 2007 at 11:04 UTC

    I belive you can access the $dbh via the Storage class:

    my $dbh = $self->schema->storage->dbh;

    --
    "Go up to the next female stranger you see and tell her that her "body is a wonderland."
    My hypothesis is that she’ll be too busy laughing at you to even bother slapping you.
    " (src)

      Great! 10x! It's working! DBIx creates connection at every query? Or it uses sheared dbhandle? May be you read it before me )
        DBIx::Class re-uses existing connections. It checks if connections are still open: if so they are re-used otherwise it reconnects.

        Please note DBIx::Class is not sharing connections: every my $schema = My::DB->connect('dbi:mysql:DB', 'user', 'secret_password'); will remain separate from every other connection, but every query within an individual $schema will re-use the same connection as long as it is still open. Connections only get closed when the script finishes or when explicitly closed ($schema->disconnect;) or when timed-out server-side.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://634006]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-29 08:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found