CodeIgniter Forums
template parser and same field names between models - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: template parser and same field names between models (/showthread.php?tid=26644)



template parser and same field names between models - El Forum - 01-19-2010

[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!


template parser and same field names between models - El Forum - 01-20-2010

[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 .....


template parser and same field names between models - El Forum - 01-20-2010

[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