开发者

CakePHP - Set recursive to -1 in AppModel then use Containable behaviour as appropriate

开发者 https://www.devze.com 2022-12-24 10:55 出处:网络
When using CakePhp would it be advisable to set recursive = -1 in the AppModel class and then use the Containable Behaviour whenever you need a deeper da开发者_C百科ta relationship?

When using CakePhp would it be advisable to set recursive = -1 in the AppModel class and then use the Containable Behaviour whenever you need a deeper da开发者_C百科ta relationship?

I believe this would give my applications the best chance of avoiding database related sluggish performance but is the methodology sound?

Thanks

Leo


I use the Containable behaviour on every query. If there is no need for a deeper relationship I use $params['contain'] = array(); -> I don't use recursive at all anymore


leo i see what you are trying to do, and its a pretty good idea, but what i prefer to do on all my relations is set the fields for each relation, so i would just pull the name and id.

this way you have the data and the joins are not to bad.

0

精彩评论

暂无评论...
验证码 换一张
取 消