db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Vandahl <thomas.vand...@tewisoft.de>
Subject Re: count rows in a table
Date Wed, 31 Aug 2005 06:19:28 GMT
barak wrote:
> Hi,
>  
> I wanted to know if there is a way in the new version of torque to use
> "count *" (or any other count) from a peer.
> I saw there is an option using CountHelper like this: 
> new CountHelper().count(new Criteria("MyDatabase").add(
> some_kind_of_criterion ))
>  
> Is there a way to use something like this from the peer so I won't have
> to insert my database name each peer?

I used to use something like the following for counting rows:

	Criteria criteria = new Criteria();
	criteria.addSelectColumn("COUNT(" + MytablePeer.ID + ")");
	
	// add where conditions here ...

	List result = BasePeer.doSelect(criteria);
	int count = ((Record)result.get(0)).getValue(1).asInt();

Hope it helps

Bye, Thomas.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message