… | |
… | |
50 | |
50 | |
51 | Connect to the database given by C<($dsn,$user,$pass)>, while using the |
51 | Connect to the database given by C<($dsn,$user,$pass)>, while using the |
52 | flags from C<$flags>. These are just the same arguments as given to |
52 | flags from C<$flags>. These are just the same arguments as given to |
53 | C<DBI->connect>. |
53 | C<DBI->connect>. |
54 | |
54 | |
55 | The database handle will be cached under the unique id C<$id>. If the same |
55 | The database handle will be cached under the unique id |
56 | id is requested later, the cached handle will be checked (using ping), and |
56 | C<$id|$dsn|$user|$pass>. If the same id is requested later, the |
|
|
57 | cached handle will be checked (using ping), and the connection will |
57 | the connection will be re-established if necessary (be sure to prefix your |
58 | be re-established if necessary (be sure to prefix your application or |
58 | application or module name to the id to make it "more" unique. Things like |
59 | module name to the id to make it "more" unique. Things like __PACKAGE__ . |
59 | __PACKAGE__ . __LINE__ work fine as well). |
60 | __LINE__ work fine as well). |
|
|
61 | |
|
|
62 | The reason C<$id> is necessary is that you might specify special connect |
|
|
63 | arguments or special flags, or you might want to configure your $DBH |
|
|
64 | differently than maybe other applications requesting the same database |
|
|
65 | connection. If none of this is becessary for your application you can |
|
|
66 | leave $id empty (i.e. ""). |
60 | |
67 | |
61 | If specified, C<$connect> is a callback (e.g. a coderef) that will be |
68 | If specified, C<$connect> is a callback (e.g. a coderef) that will be |
62 | called each time a new connection is being established, with the new |
69 | called each time a new connection is being established, with the new |
63 | C<$dbh> as first argument. |
70 | C<$dbh> as first argument. |
64 | |
71 | |