in reply to Re: how to put this db connection code into a function
in thread how to put this db connection code into a function
I suppose the above leaves RaiseError in the wrong state for subsequent prepare and other calls. Fixed:
sub connect { return eval { DBI->connect( "DBI:mysql:".join(';', "database=$sql_database", "host=$sql_host", "port=$sql_port", ), $username, $password, { RaiseError => 1, AutoCommit => 1, }, ) }; }; my $dbh = connect() or die("Can't connect: $DBI::errstr\n");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to put this db connection code into a function
by Anonymous Monk on Jan 05, 2011 at 00:19 UTC | |
by ikegami (Patriarch) on Jan 05, 2011 at 01:11 UTC |