You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "Post, Andreas (FF)" <an...@t-systems.com> on 2002/10/23 10:56:05 UTC

BasePeer.executeQuery and #foreach

Hello !

I need some help for a simple question,  I guess.
Because I have a very tricky "join,group by" Statement, I want to do it
without criteria.

I m using the following, and it works:

	List  L=BasePeer.executeQuery("SELECT a,b FROM TABLE");
	context.put("list", L);

but I can´t get the elements in the template:

#foreach ( $row in $list )
	$row.a
	$row.b
#end
That would be beautiful, but it doesn't work.

Does anybody have an answer to get the collumns ?

thank you

Greetings 
Andreas Post

Re: BasePeer.executeQuery and #foreach

Posted by Peter Courcoux <pe...@courcoux.biz>.
On Wed, 2002-10-23 at 18:15, Peter Courcoux wrote:
> Andreas,
> 
> BasePeer.executeQuery("...") returns a com.workingdogs.village.Record
> object. To get the value from that you need to do something like :-

Whoops! No! It does, of course, return a List of
com.workingdogs.village.Record objects.

> 
> 
> 
> $row.getValue("a").asInt() // asString() etc. whatever is appropriate.
> $row.getValue("b").asInt() // asString() etc. whatever is appropriate.
> 
> See javadocs at
> http://share.whichever.com/village/village-1.5.3/docs/apidocs/
> 
> Hope that helps.
> 
> Regards,
> 
> Peter Courcoux
> 
> 
> 
> 
> On Wed, 2002-10-23 at 09:56, Post, Andreas (FF) wrote:
> > Hello !
> > 
> > I need some help for a simple question,  I guess.
> > Because I have a very tricky "join,group by" Statement, I want to do it
> > without criteria.
> > 
> > I m using the following, and it works:
> > 
> > 	List  L=BasePeer.executeQuery("SELECT a,b FROM TABLE");
> > 	context.put("list", L);
> > 
> > but I can´t get the elements in the template:
> > 
> > #foreach ( $row in $list )
> > 	$row.a
> > 	$row.b
> > #end
> > That would be beautiful, but it doesn't work.
> > 
> > Does anybody have an answer to get the collumns ?
> > 
> > thank you
> > 
> > Greetings 
> > Andreas Post
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: BasePeer.executeQuery and #foreach

Posted by Peter Courcoux <pe...@courcoux.biz>.
Andreas,

BasePeer.executeQuery("...") returns a com.workingdogs.village.Record
object. To get the value from that you need to do something like :-



$row.getValue("a").asInt() // asString() etc. whatever is appropriate.
$row.getValue("b").asInt() // asString() etc. whatever is appropriate.

See javadocs at
http://share.whichever.com/village/village-1.5.3/docs/apidocs/

Hope that helps.

Regards,

Peter Courcoux




On Wed, 2002-10-23 at 09:56, Post, Andreas (FF) wrote:
> Hello !
> 
> I need some help for a simple question,  I guess.
> Because I have a very tricky "join,group by" Statement, I want to do it
> without criteria.
> 
> I m using the following, and it works:
> 
> 	List  L=BasePeer.executeQuery("SELECT a,b FROM TABLE");
> 	context.put("list", L);
> 
> but I can´t get the elements in the template:
> 
> #foreach ( $row in $list )
> 	$row.a
> 	$row.b
> #end
> That would be beautiful, but it doesn't work.
> 
> Does anybody have an answer to get the collumns ?
> 
> thank you
> 
> Greetings 
> Andreas Post


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


AW: BasePeer.executeQuery and #foreach

Posted by Marc Lustig <ma...@marclustig.com>.
> -----Ursprüngliche Nachricht-----
> Von: Post, Andreas (FF) [mailto:andreas.post@t-systems.com]
> Gesendet: Mittwoch, 23. Oktober 2002 10:56
> An: 'turbine-user@jakarta.apache.org'
> Betreff: BasePeer.executeQuery and #foreach
>
>
> Hello !
>
> I need some help for a simple question,  I guess.
> Because I have a very tricky "join,group by" Statement, I want to do it
> without criteria.
>
> I m using the following, and it works:
>
> 	List  L=BasePeer.executeQuery("SELECT a,b FROM TABLE");

Usually you query not the BasePeer, but your business object(BO) Peer class,
like
MyboPeer.executeQuery("SELECT...");

> 	context.put("list", L);
>
> but I can´t get the elements in the template:
>
> #foreach ( $row in $list )
> 	$row.a
> 	$row.b
> #end
> That would be beautiful, but it doesn't work.

It does so, provided that your BO has getter-methods that correspond to the
fields of your table. BOs generated by Torque provide these methods
automatically.

HTH.
Marc


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>