[Zope-DB] result set question

Christian Theune ct@gocept.com
Wed, 13 Mar 2002 14:20:25 +0100


Hi Joel.

* Joel Burton <joel@joelburton.com> [020313 13:40]:
> Splitting results is easy. Look at the Help docs for <dtml-in> and you'll
> see the commands for batching.
> 
> You might want to create a separate ZSQLMethod for the detail view of an
> object, or you might want to share your list-getting method. You can do
> things like:
> 
> # ZSQLMethod
> # parameters: fooid:optional
> SELECT * FROM tblFoo
> <dtml-if fooid>
> WHERE fooid=<dtml-sqlvar fooid type=foo>
> </dtml-if>

dtml provides some special things for that (they just got fixed ...)

<dtml-sqlgroup where>
	<dtml-sqltest fooid type="int" optional>
</dtml-sqlgroup>

Would do the same.

Greetings.

Christian

> 
> And you can call this method w/o an id to get all records, or with an id to
> get just one. The downside is that it's less clear and that you're getting
> all fields for your list; if your table has many long fields, this is
> unneccessary work. However, it is less to write and less to maintain.
> 

I would provide 2 Queries, for the case you don't want to retrieve all fields of a set
or need to join some other tables for the detail view. This would save some speed and memory.

-- 
Christian Theune - ct@gocept.com
gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt
tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981

reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])