문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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

You should read the model relationships page.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top