He there,
I have two tables in my database: "Achievements" and "AchievementsCompleted". I would like to select all of the Achievements unless there is an AchievementCompleted entry with that achievement as foreign key constraint.
So for example:
There are 3 rows in the table Achievement:
- ID: 1 - Achievement1
- ID: 2 - Achievement2
- ID: 3 - Achievement3
and there is one entry in the table AchievementCompleted:
- achievement_id = 2 completed by user 3
In that case I would like the output to be only the models of id 1 and 3 for user 3.
$criteria = new CDbCriteria();
$criteria->condition = "";
$models = Achievements::model()->findAll($criteria);
Thanks in advance! I hope this makes sense.