Welcome Guest, Not a member yet? Register   Sign In
template parser and same field names between models
#1

[eluser]Federico Gonzalez[/eluser]
Hi,

I have a problem parsing data (using template parser) with same fields names between tables. I have three database tables:

persons: id, name, country_id
foods: id, name
foods_persons: person_id, food_id

In view file:

<p>Person name: {name}</p>
<p>Countries: </p>
<ul>
{countries}
<li>{name}</li>
{/countries}
</ul>

The field name it's same field-name in both tables.

How can I parse correctly mantaining the original fields-names ?

(sorry by my english)

Thanks!
#2

[eluser]imn.codeartist[/eluser]
persons: id, name, country_id
foods: id, name
foods_persons: person_id, food_id

select p.id as pid,p.name as person_name,p.country_id,
f.id as fid,f.name as food_name,fp.person_id,fp.foo_id from persons p, foods f, foods_persons fp .....
#3

[eluser]Federico Gonzalez[/eluser]
Thanks, this works for query based models. But I'm using datamapper ORM (dmz version) and then.. I can't rename the names of fields (or at least I think)

Some idea?

regards, Federico




Theme © iAndrew 2016 - Forum software by © MyBB