[Zope-DB] return count() from mysql in zope
dieter at handshake.de
Sun Sep 5 14:59:43 EDT 2004
James R. Saker Jr. wrote at 2004-9-4 13:58 -0500:
>SELECT COUNT(pkID) FROM animals WHERE animalTypeID = 3;
>Within Zope, I'm not sure whether to tackle this via DTML or via a
Both will work.
>I've tried dtml-call
Please reread the "dtml-call" description. You miss the essential
use case for "dtml-call" (no return value!).
>and that's not working, as well as a
>few other approaches and clearly am missing something obvious given how
>easy this should be... ideas?
You miss (almost surely) that the result of any "select" Z SQL Method
is a sequence like object -- even when the result consists of a single
row. You have to access this single row explicitly "result".
You further miss that the Z SQL Method wants to make columns accessible
via a name. Thus, each column of your result should have a name.
Use "as" to provide a name for columns resulting from function calls
in your query.
select count(XXX) as count ....
More information about the Zope-DB