chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.web-live.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Generalise dumpqueryresults and rename to dumptable
[ypp-sc-tools.web-live.git]
/
yarrg
/
web
/
dumptable
diff --git
a/yarrg/web/dumpqueryresults
b/yarrg/web/dumptable
similarity index 79%
rename from
yarrg/web/dumpqueryresults
rename to
yarrg/web/dumptable
index 8860ace69fa285e7cbde63beb399c75dd7050c7f..20dc25f12ceb4ea7a77e51302e7ec9557b53e10a 100644
(file)
--- a/
yarrg/web/dumpqueryresults
+++ b/
yarrg/web/dumptable
@@
-30,21
+30,22
@@
This Mason component is helpful for debugging and developing. It
This Mason component is helpful for debugging and developing. It
- outputs
SQL query results as HTML table
s. You can either:
- <& dump
queryresults
, sth = $executed_statement_handle &>
+ outputs
plain HTML tables eg for SQL query result
s. You can either:
+ <& dump
table
, sth = $executed_statement_handle &>
in which case it will consume the results of the statement and
print them unconditionally, or do the equivalent of:
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) {
% my $row;
% while ($row= $sth->fetchrow_hashref) {
- <& dump
queryresults:row, sth => $sth
, row => $row, [ qa => $qa ] &>
+ <& dump
table:row, sth|cols => ...
, row => $row, [ qa => $qa ] &>
% do something else with $row
% }
% do something else with $row
% }
- <& dump
queryresults
:end, [ qa => $qa ] &>
- where if you pass $qa, dump
queryresults
will check whether debug
+ <& dump
table
:end, [ qa => $qa ] &>
+ where if you pass $qa, dump
table
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
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 dump
queryresults'
table.
+ interleaved with dump
table's
table.
</%doc>
<%args>
</%doc>
<%args>
@@
-53,13
+54,14
@@
$sth
<%method start>
<%args>
<%method start>
<%args>
-$sth
+$sth => undef
+$cols => $sth->{NAME}
$qa => undef
</%args>
% if (!$qa || $qa->{'debug'}) {
<table frame=box rules=all>
<tr>
$qa => undef
</%args>
% if (!$qa || $qa->{'debug'}) {
<table frame=box rules=all>
<tr>
-% foreach my $field (@
{ $sth->{NAME} }
) {
+% foreach my $field (@
$cols
) {
<th><% $field |h %>
% }
</tr>
<th><% $field |h %>
% }
</tr>
@@
-68,13
+70,14
@@
$qa => undef
<%method row>
<%args>
<%method row>
<%args>
-$sth
+$sth => undef
+$cols => $sth->{NAME}
$row
$qa => undef
</%args>
% if (!$qa || $qa->{'debug'}) {
<tr>
$row
$qa => undef
</%args>
% if (!$qa || $qa->{'debug'}) {
<tr>
-% foreach my $field (@
{ $sth->{NAME} }
) {
+% foreach my $field (@
$cols
) {
% my $cell= $row->{$field};
<td>
<% $cell |h %>
% my $cell= $row->{$field};
<td>
<% $cell |h %>