0

Im new to cakePHP and the whole table relations concept is very confusing!

I have 2 tables, competencies and competenceRatings. competencies stores a list of names with ids.

competencies
------------
id
name

And users can select various competencies from this table and rate them and their ratings are stored into competenceRatings table.

competenceRatings
-----------------
id
competence_id
user_id
rating

I want to be able to get the names of competencies for which a user have NOT made any ratings into competenceRatings table. i.e., I need list of names from competencies table for which there are no entries in comptenceRatings table(for given user_id).

I tried competencies->hasMany->competenceRatings, competenceRatings->belongsTo->competencies relations.

$competencies = $this->Competence->CompetenceRating->find('all',array('CompetenceRating.user_id' => $userId,'CompetenceRating.competence_id !=' => 'Competence.id'));

But no use!

Does this result require any other relations? Or can i just join tables using joins condition in find query?

Thanks.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by iamthwee
0

Not sure exactly but a tip.

If you download navicat trial version you can create table joins visually, which is a lot easier when creating queries by hand.

Might be an idea.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.