-----Ursprüngliche Nachricht-----
Von: John Chambers [mailto:JLCh...@klikwood.com]
Gesendet: Freitag, 6. Januar 2006 15:39
A few weeks ago, I upgraded an old Debian system to Sarge, and I started
receiving these error messages:
DBI->connect using 'old-style' syntax is deprecated and will
be an error in future versions at blib/lib/invlib.pm line 20
in my apache logs.
Now, I'm building a newer system from scratch, and when I
make test my local modules, I'm getting that message.
The scripts still work, but I prefer no warnings
Good idea.
What is the new syntax? Here is my call:
(my $dbh = DBI->connect( 'sheet', 'jc', 'secret', 'mysql' ) ) or die
"Cannot do \$dbh->connect: $DBI::errstr\n";
A very brief look into the DBI docs reveals:
$dbh = DBI->connect($data_source, $username, $password)
or die $DBI::errstr;
$dbh = DBI->connect($data_source, $username, $password, \%attr)
or die $DBI::errstr;
[...]
Examples of $data_source values are:
dbi:DriverName:database_name
dbi:DriverName:database_name@hostname:port
dbi:DriverName:database=database_name;host=hostname;port=port
[...]
For compatibility with old DBI scripts, the driver can be specified by
passing its name as the fourth argument to connect (instead of \%attr):
$dbh = DBI->connect($data_source, $user, $pass, $driver);
In this ``old-style'' form of connect, the $data_source should not start
with ``dbi:driver_name:''. (If it does, the embedded driver_name will be
ignored). Also note that in this older form of connect, the
$dbh->{AutoCommit} attribute is undefined, the $dbh->{PrintError} attribute
is off, and the old DBI_DBNAME environment variable is checked if DBI_DSN is
not defined. Beware that this ``old-style'' connect will be withdrawn in a
future version of DBI.
\Gisbert