Welcome Guest, Not a member yet? Register   Sign In
Is there any way to get data through Foreign key via Datamapper?
#1

[eluser]Ricola[/eluser]
Hi there.

I'm newbie with Datamapper ORM Library.

Is it possible to get data automatically through foreign key via ORM?

MY table::

Category
-ID
-Name


Content
-ID
-Title
-Description
-CategoryID(FK)

This is my expected result:
Content (ID,Titlte,Description,CategoryName)

In the normal way we have to join these two table and get data from it but i wanna know, What is the best practice when we wanna get data like this


Thanks in advanced
#2

[eluser]WanWizard[/eluser]
Code:
$content = new Content();
$content->include_related('category', array('Name')->get();

See http://datamapper.wanwizard.eu/pages/get...de_related




Theme © iAndrew 2016 - Forum software by © MyBB