|
From: Ian B. <ia...@co...> - 2004-05-30 07:20:58
|
On May 29, 2004, at 10:53 PM, Michel Thadeu wrote:
> Hi againg guys!
>
> I wondered with SQLObject :) It's cool...
> I have tried out and had another 2 questions:
>
> How is the best way to use SQLObject over a html schema? I using
> webware and I think I can't pass the object throught requests, so I
> must pass the id and get from Table the row matching the id.
>
> I done something like this:
>
> Table.select(Table.q.id==someid)
>
> But is there a method like ByAlternateID? or is a easier way to do? The
> list index is a choice: Table.select()[someid]?
If you are using the Subversion (0.6) version, it's Table.get(someid),
or in 0.5.x it's Table(someid).
> Another question is in a join:
>
> I have 2 tables:
>
> class City:
> name=StringCol(length=100)
> state=ForeignKey('State')
>
> class State:
> name=StringCol(length=100)
> cities=MultipleJoin('City')
>
> I want to do something like:
>
> select city.name from city inner join state on city.state_id=state.id
> where city.name like '%somename%' and state.id=1;
>
> I try:
>
> [i for i in City.select((City.q.name.contains('something')) &
> (State.q.id=1))]
>
> with no sucess...
City.select(City.q.name.contains('something') & (City.q.stateID==1)).
Ian Sparks posted about a similar but slightly more complicated join
just a couple days ago, and there's another example in that thread.
--
Ian Bicking | ia...@co... | http://blog.ianbicking.org
|