I'm slightly confused as to how to reference a field when I have the
foreign key.

table pets:
pets.id
name
category (foreign key category.id)
description

table category:
category.id
category_name

I am trying to show the category name, in my show page/function,
instead of a number.

In the controller, I do a
show():
id=request.vars.id
pet=db(db.pets.id==id).select()
return dict(pet=pet[0])

In the view, among other things, I have {{=pet.category}}
Which of course returns a number.

At which point am I supposed to join the category table and the pet
table, to do a lookup for the category name?
What does the code for that look like? Does it have to be a join?

Thank you very much.
Yanni.

Reply via email to