ZSQL Method Question
Hi, 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. Cheers for any help, Chris
<dtml-in SQLQuery> <dtml-if sequence-start> <dtml-var count-xxx> ... </dtml-if> <dtml-else> <h2>No Records Found!</h2> </dtml-in> replace xxx with the name of any field that will always have a value, like the key field. This will give you a count of ALL rows returned. __________________________________________________________________ Jim Sanford . Database Engineer / \ / Accelerated Technology, Inc. / / 720 Oak Circle Drive East / / \ Mobile, AL 36609 / / \ Voice: 334-661-5770 fax: 334-661-5788 / \ E-Mail: jsanford@atinucleus.com Web: http://www.atinucleus.com Source Code, No Royalties, Any CPU...It just make sense ! __________________________________________________________________ ----- Original Message ----- From: Chris Withers <chrisw@nipltd.com> To: Zope Mailing List <zope@zope.org> Sent: Wednesday, February 23, 2000 8:59 AM Subject: [Zope] ZSQL Method Question Hi, 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. Cheers for any help, Chris _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
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
participants (3)
-
Chris Withers -
Jim Sanford -
Matt Goodall