1
我要選擇的數據形式的數據庫並顯示出來,但我有以下問題:Can't call method "fetchrow_array" without a package or object reference
無法調用「fetchrow_array」沒有包裝或對象引用
test.pl
我的$ Q =新的CGI();
my $handle = Db::connection();
sub select{
my $rData = {
table => 'student',
condition => {
ID => 100,
}
};
return Db::select($rData);
};
print $q->header;
print $q->start_html(
-title => "Main",
-style => {-src =>'/media/css/start/jquery-ui-1.10.3.custom.css" rel="stylesheet' },
-script => [
{ -src=>'/media/js/jquery-1.9.1.js'},
{ -src=>'/media/js/jquery-ui-1.10.3.custom.js'},
{ -src=>'/media/js/jquery.dataTables.js'},
]
);
my $cScript = qq{
\$(document).ready(function(){
oTable = \$('#id_table').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
});
\$("input[type=button], a, button")
.button()
.click(function(event){
event.preventDefault();
});
});
};
print $q->script($cScript);
print start_form (-method => 'post', -action => "");
my @aRows;
my $sqlSelect = Dbm::get_list({
table => 'personi',
condition => {
ID => 100,
}
});
while (my @data = $sqlSelect->fetchrow_array()) {
my $cRowId = hidden('rowid', $data[0]);
my $bt1 = image_button({-src => '/media/images/delete_1.png',
-class => 'del',
-title => 'delete',
-name => 'delete',
-value => $data[0],
my $bt2 = image_button({-src => '/media/images/edit_1.png',-class => 'upd', -title => 'update', -name => 'update', -value => $data[0]});
push @aRows, ($cRowId, $q->Tr($q->td([$data[1], $data[2], $data[3], $bt1, $bt2])));
}
print $q->table({-border => '1px solid green',-align =>'center', -width => '100%', -id => 'id_table'},
thead($q->th(['Name', 'Surname', 'Age', 'Delete', 'Edit'])),
@aRows,
);
print $q->input({-type => 'button', -class => 'button', -onclick => "window.location.href='insert.pl';", -value => 'Shto'});
print $q->end_form;
print test_select();
我不明白哪裏可能是問題。我是這種語言的新手,需要一些幫助
是這樣的? $ sqlSelect-> execute or die「無法執行查詢:$ sqlSelect-> errstr」; – Armida
不行,後面的那行是'return $ sqlSelect;'(並且沒有返回該行)。 –