my $config = "";
my $dsn = "dbi:SQLite:dbname=test.db";
my $dbh = DBI->connect(
$dsn,
"",
"",
{ RaiseError => 1}
) or die $DBI::errstr;
my $sth = $dbh->prepare("SELECT config FROM tests WHERE status=1");
$sth->execute();
my $config = $sth->fetchrow();
if($config ne "")
{
print "found!"
}
$sth->finish();
$dbh->disconnect();
爲什麼我越來越
Use of uninitialized value $config in string ne at .....
打開;'和'使用警告;'。可能'fetchrow'正在返回undef。爲什麼你測試它是一個空字符串呢? – Sobrique 2014-11-24 17:41:04
我加入'use strict;使用警告;使用DBI;'到我的代碼 – 2014-11-24 17:42:04
數據庫中的'config'爲空嗎? – AKHolland 2014-11-24 17:42:13