1111
Perl / Помогите разобраться с обработкой запросов MySQL.
« : 12 Августа 2001, 18:13:34 »Цитировать
use CGI qw(:standard);
use DBI;
<-- пропущено -->
if ($action eq "show_table") {
my $table_data = $dbh -> prepare("SELECT * from $activ_tbl_name");
$table_data -> execute;
if (not $table_data) {
print "nno such table or no datan"; exit(0);
}
my @fields = @{$table_data -> name};
my @types = @{$table_data -> type};
my @not_null = @{$table_data -> is_not_null};
my @length = @{$table_data -> length};
print "n";
foreach $field (0..$#fields) {
print $fields[$field]
}
}
<-- пропущено -->
perldoc DBI
Код: [Выделить]
execute
$rv = $sth->execute || die $sth->errstr;
$rv = $sth->execute(@bind_values) || die $sth->errstr;
Perform whatever processing is necessary to execute the prepared
statement. An undef is returned if an error occurs. A successful
execute always returns true regardless of the number of rows affected,
even if it\'s zero (see below). It is always important to check the
return status of execute (and most other DBI methods) for errors.
Код: [Выделить]
For SELECT statements, execute simply ``starts\'\' the query within the
database engine. Use one of the fetch methods to retreive the data after
calling execute. The execute method does not return the number of
rows that will be returned by the query (because most databases can\'t
tell in advance), it simply returns a true value.
Надеюсь все понятно?