"tamara6" <[EMAIL PROTECTED]> writes:

Hi All,

I'm just learning Turbogears and SQLObject.  I'm redoing a project that
I've done already in PHP.  I am using a MySQL database.  This is an
application that chooses selected problems from a database, randomly
orders them, and shows them on the web page.

Using PHP, the way I was randomizing the questions was by using Order
By Rand().  From what I can see, it looks like SQLObject does not
support this.  Has anyone else done this sort of thing before?  Is
there a standard way to do this?

import mode
from sqlobject import sqlbuilder
list(model.Visit.select(orderBy=sqlbuilder.func.random())[:10])


This should select 10 random visits from the database.  (random() is a
PostgreSQL function, in my case...  you'll probably write rand())


Be seeing you,
--
Jorge Godoy      <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to