-3

After setting up my database and baking, the model associations declared are not correct.

eg instead of seeing hasOne i see hasAndBelongsToMany

so my question here is for examples of sql tables that would generate the 4 correct associations when baked.

tereško
  • 58,060
  • 25
  • 98
  • 150
Simba
  • 522
  • 1
  • 5
  • 9
  • 1
    I doubt anyone is able to tell you anything for that little you are offering (or asking for that matter). too much information missing... where is your actual sql or table setup? was did you do exactly? etc – mark Sep 07 '12 at 00:12

2 Answers2

2

The quick anwser is, if you have a foreign key, bake will try a a hasMany relationship or a hasOne if you deny the first, and follow a belongsTo on the other model. If you have a join table It will try to bake a hasAndBelongsToMany instead.

petervaz
  • 13,685
  • 1
  • 15
  • 15
0

If you follow Cake conventions, then the bake tool will usually guess the correct relationships.

You should read the model relationships page.

Ivo
  • 5,378
  • 2
  • 18
  • 18