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.

Member Avatar for iamthwee

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.