There appear to be 2 things wrong with your setup.
- You are not following Cake database conventions. Unless your hands are tied (e.g. external datasource you have no control over), your primary key should always be called
id
, nottable_name_id
. Cake always looks forid
keys by default. If you have no choice, you can set a custom primary key by setting the primaryKey property in your model. - By looking at your tables, you seem to be mixing up hasOne with belongsTo. Even though in plain English it sounds logical that a donor has one blood group, from a database standpoint, the donor belongs to a certain blood group. The manual has some notes that help you pick the right one:
hasOne: the other model contains the foreign key.
belongsTo: the current model contains the foreign key.
This is also illustrated with some examples in the documentation (see links above). The latter one is true in your case, so your model should eventually look like this:
class Donor extends AppModel {
public $belongsTo = array(
'BloodGroup',
'DonorType'
);
}