[eluser]imohammad[/eluser]
Thank you Simon! really appreciate your help.
I somehow asked the wrong question
but glad you answered again.
Anyway, I'm having a problem since yesterday with joining many to many relations.
I have the following tables:
Groups
Groups_Users
Skills
Users
Skills_Users
I want to get a list of users based on the group filter and skill filter
What I tried:
Code:
$group = new Group();
$user = new User();
$skill = new Skill();
$group->where('title', 'dev')->get();
$skill->where('title', 'php');
$skill->where('title', 'java');
$user->where_related($group)->get() // retrieves all users in dev group
$user->where_related($skill)->get(); // retrieves all users either in dev group or not with the above skills
I could do this using sql statements easily, but I'm trying to get my head around this whole ORM for my work.
[quote author="Maglok" date="1406012655"]You got a table called User and a table called User_profile. You make two datamapper extending classes using the template file.
Then you can create new instances of those tables with:
Code:
$user = new User();
// Get all users
$user->get();
Now you need to create a relationship between the two. If it is a 1 on 1 (which seems likely) you can add a user_id foreign key to the User_profile table. Then in the datamapper code create a simple relationship as in the manual.
You can then access your profile info like so:
Code:
$user = new User();
// Get all users
$user->get();
// Get specific data from profile
echo $user->user_profile->address;
That any help?[/quote]