[Zope] Simple, I think!

Thomas B. Passin tpassin@mitretek.org
Wed, 25 Jul 2001 17:21:40 -0400


[Phil Harris]

> Why don't you let the query itself count the record?
>
> e.g.
>
> select count(*) as tcount from sometable
> where somecolumn='somevalue'
>
You don't want to do this, because either you have to go to the database
twice - once for the data and once for the count - or you have to return the
count for each row which is annoying at least.

> DTML is not really the right toolfor this job, SQL is!
>

Sure it is.  Just call the len() function on the result returned by the
query:

 <dtml-let results=your_query_method>
  ===<dtml-var "_.len(results)">====
</dtml-let>

I just tried it to confirm my memory, and it worked fine.

Cheers,

Tom P