X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Fdumptable;fp=yarrg%2Fweb%2Fdumpqueryresults;h=20dc25f12ceb4ea7a77e51302e7ec9557b53e10a;hb=bdad24af2d97e3448b671da80bb4247411bafbea;hp=8860ace69fa285e7cbde63beb399c75dd7050c7f;hpb=641e98def7ea904b48b0f7dc22d868b40f3cff1b;p=ypp-sc-tools.db-live.git diff --git a/yarrg/web/dumpqueryresults b/yarrg/web/dumptable similarity index 79% rename from yarrg/web/dumpqueryresults rename to yarrg/web/dumptable index 8860ace..20dc25f 100644 --- a/yarrg/web/dumpqueryresults +++ b/yarrg/web/dumptable @@ -30,21 +30,22 @@ This Mason component is helpful for debugging and developing. It - outputs SQL query results as HTML tables. You can either: - <& dumpqueryresults, sth = $executed_statement_handle &> + outputs plain HTML tables eg for SQL query results. You can either: + <& dumptable, sth = $executed_statement_handle &> in which case it will consume the results of the statement and print them unconditionally, or do the equivalent of: - <& dumpqueryresults:start, sth => $sth, [ qa => $qa ] &> + <& dumptable:start, sth => $sth, [ qa => $qa ] &> or + <& dumptable:start, cols => [ 'column',... ], [ qa => $qa ] &> % my $row; % while ($row= $sth->fetchrow_hashref) { - <& dumpqueryresults:row, sth => $sth, row => $row, [ qa => $qa ] &> + <& dumptable:row, sth|cols => ..., row => $row, [ qa => $qa ] &> % do something else with $row % } - <& dumpqueryresults:end, [ qa => $qa ] &> - where if you pass $qa, dumpqueryresults will check whether debug + <& dumptable:end, [ qa => $qa ] &> + where if you pass $qa, dumptable will check whether debug is enabled and produce no output if it isn't. NB you don't want this approach if your loop body produces output because it'll be - interleaved with dumpqueryresults' table. + interleaved with dumptable's table. <%args> @@ -53,13 +54,14 @@ $sth <%method start> <%args> -$sth +$sth => undef +$cols => $sth->{NAME} $qa => undef % if (!$qa || $qa->{'debug'}) { -% foreach my $field (@{ $sth->{NAME} }) { +% foreach my $field (@$cols) { @@ -68,13 +70,14 @@ $qa => undef <%method row> <%args> -$sth +$sth => undef +$cols => $sth->{NAME} $row $qa => undef % if (!$qa || $qa->{'debug'}) { -% foreach my $field (@{ $sth->{NAME} }) { +% foreach my $field (@$cols) { % my $cell= $row->{$field};
<% $field |h %> % }
<% $cell |h %>