Forum Webscript.Ru
Программирование => Perl => Тема начата: systemroot от 26 Января 2005, 10:39:38
-
Скрип валиться с ошибкой при выполнений куска кода
my $sth=$dbh->do("select max(DogID) as maxID from Dogs where DogID<$DogID_Hi AND DogID>$DogID_Low");
my $row = $sth->fetchrow_hashref();
my $MaxDogID=$row->{\'maxID\'}+1;
Ошибка: Can\'t call method "fetchrow_hashref" without a package or object reference
-
systemroot
Естественно...
Команда SELECT не работает через do
my $sql = "SELECT ... ";
my $sth = $dbh->prepare($sql); $sth->execute();
my $row = $sth->fetchrow_hashref();
$sth->finish();
http://www.perldoc.narod.ru/perl-dbi_ref.pdf
-
systemroot:
my $sth=$dbh->do("select max(DogID) as maxID from Dogs where DogID<$DogID_Hi AND DogID>$DogID_Low");
ты бы что ли документацию почитал по DBI..
This method is typically most useful for non-SELECT statements that either cannot be prepared in advance (due to a limitation of the driver) or do not need to be executed repeatedly. It should not be used for SELECT statements because it does not return a statement handle (so you can\'t fetch any data).
$sth=$dbh->prepare($sql);
$sth->execute;
my $row = $sth->fetchrow_hashref();
-
Виноват пропустил.
Но вот это я понять не могу
Can\'t use string ("5329") as an ARRAY ref while "strict refs" in use at
-
systemroot:
Но вот это я понять не могу
Can\'t use string ("5329") as an ARRAY ref while "strict refs" in use at
мы тоже, пока ты не объяснишь когда, где и при каких условиях она вываливается.