
[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
Re: [ic] Number of results from a [query]
Quoting Peter Jakl (peter@jakl.net):
> Is there a subtag available to know how many rows are returned on an sql
> [query]?
>
> I want to do the following:
>
> [query list=1 sql="select * from table"]
>
> [if <number of rows returns> > 1]
> [list]
> [sql-code] .
> [/list]
> [/if]
>
You can get it with [matches] in a more-list area, but I don't think
that helps you.
It seems that we need to put something like this in to help you:
[on-match == 1]
<hr>
Match was exactly 1.
[search-list]
[item-increment]. [item-field description]<BR>
[/search-list]
[/on-match]
[on-match > 1]
<hr>
Match was greater than 1.
[search-list]
[item-increment]. [item-field description]<BR>
[/search-list]
[/on-match]
[on-match < 5]
<hr>
Match was less than 5.
[search-list]
[item-increment]. [item-field description]<BR>
[/search-list]
[/on-match]
[on-match > 5]
<hr>
Match was greater than 5. Whooiee!!!
[/on-match]
This is actually easy to do, and I did it. Try this patch against
4.8.x (lines may be off):
--- /R/Interpolate.pm Thu Oct 18 12:24:36 2001
+++ /tmp/Interpolate.pm Thu Nov 15 20:44:10 2001
@@ -417,7 +417,7 @@
'more' => qr($T{more}\]),
'more_list' => qr($T{more_list}$Optx$Optx$Optx$Optx$Optx\]($Some)$T{'/more_list'}),
'no_match' => qr($T{no_match}\]($Some)$T{'/no_match'}),
- 'on_match' => qr($T{on_match}\]($Some)$T{'/on_match'}),
+ 'on_match' => qr($T{on_match}$Optr\]($Some)$T{'/on_match'}),
'quantity_name' => qr($T{quantity_name}\]),
'then' => qr(^\s*$T{then}$T($Some)$T{'/then'}),
);
@@ -5462,7 +5462,7 @@
$obj->{matches} > 0 ? '' : $1
!ge;
$page =~ s!$QR{on_match}!
- $obj->{matches} <= 0 ? '' : $1
+ pull_if($2,0,$1,$obj->{matches})
!ge;
$page =~ s:\[$prefix\]($Some)\[/$prefix\]:labeled_list($opt,$1,$obj):ige
or $page = labeled_list($opt,$page,$obj) ;
--
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH 45013
phone +1.513.523.7621 <mheins@redhat.com>
Any man who is under 30, and is not liberal, has not heart; and any man
who is over 30, and is not a conservative, has not brains.
-- Winston Churchill
_______________________________________________
interchange-users mailing list
interchange-users@interchange.redhat.com
http://interchange.redhat.com/mailman/listinfo/interchange-users