> This is not a good solution if you have a big set of data, but it's the
> recommended way to do it in SO (the OO way):
>
> smiths = [x for x in SOClass.select() if x.lastname.find('smith.') >= 0]
>
> If your dataset is too big for doing this you could /optimize/ it with
> SQLBuilder as Diez said.

I'm really sorry to be a pain about this, but I guess I'm just slow at
understanding.  Let me be very specific.

I have a table named Question.  It has 3 columns: an id column, a
question column, and an answer column.  Question.question is typically
a sentence, with several words and whitespaces.  This is how I've been
able to search for questions that contain a specific word, like
"tree":

result = Question.select(Question.q.question.contains('tree'))

This results in an sql query like this:
SELECT question.id, question.question, question.answer FROM question
WHERE ((question.question) LIKE ('%tree%'))

This works, but I'd like to know how to do it the OO way with SO, I
guess using a construct similar to
smiths = [x for x in SOClass.select() if x.lastname.find('smith.') >=
0]

I'm afraid that I'm not able to get this to work.  Could someone
please show me what I should be doing?

Also, I'd like to know if it is wrong to use the SQLBuilder way to do
it.  I'm just learning how to use an ORM, I've spent several years
using PHP and other languages and writing my own sql queries.  I want
to learn how to use these new tools correctly, but I'm not sure what
that is.

Thanks,

Tamara



--~--~---------~--~----~------------~-------~--~----~
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