[Zope] ZSQL Method Question

Matt Goodall mgg@isotek.co.uk
Wed, 23 Feb 2000 17:09:13 +0000


Chris Withers wrote:

> Does anyone know how I can find out the number of rows returned by a select
> statement in a Z SQL method?
> 
> basically, I've got a form which has one row for each row in the database, I
> need to put a hidden count input in so the DTML method which processes the form
> knows how many rows to expect.

If your SQL Method is called sql_GetAll then you can do something like:

<!-- Get the rows -->
<dtml-call "REQUEST.set('rows',sql_GetAll())">

<!-- Display the total number of rows -->
<dtml-var "_.len(rows)">

<!-- Display the records -->
<dtml-in rows>
  <!-- whatever -->
</dtml-in>

That way you can unlink the code that writes the hidden form input field
from the dtml-in code.

HTH.

/Matt