What does "domain" mean in model context? [CakePHP/2]

Documentation for Model::$recursive says this:

  • 1 CakePHP fetches Group data only, no joins.
  • 0 CakePHP fetches Group data and its domain
  • 1 CakePHP fetches a Group, its domain and its associated Users
  • 2 CakePHP fetches a Group, its domain, its associated Users, and the Users’ associated Articles

What does “domain” mean here? Searching for “domain” only finds vague references and in other context (gettext or DNS).

From the paragraph above in the doc…

Imagine your application features Groups which belong to a domain and have many Users which in turn have many Articles.

Here, I think the word “domain” is simply referring to a possible parent record type for Groups. Basically, you could consider it as a super-group or topic area. For example, if CakePHP was a group in your system, than its “domain” could be PHP. As opposed to, say, JavaScript or Ruby, which would be domains that other groups would fall under.

So in this example… A Domain hasMany Groups which hasMany Users which hasMany Articles.

1 Like

Now I understand it. Unless you disable recursiveness entirely with -1 you always get an additional level in the opposite direction. I was confused because all sample terms are in capital letters except domain.

Thank you!

Yeah, I think it took me a while to figure out how much data the recursive settings pulled (as I recall, the docs used to be less clear about this). The auto-magic in 2.x was great, but you often didn’t know what you were getting by default, and the all-or-nothing approach on parent and child associations was a bit hard to optimize.

Thankfully, this is one area that has been greatly improved and makes a lot more sense in 3.x. Now you can explicitly specify which associations you want to pull, and it’s a lot more initiative.

1 Like

Just to let you guys know, I did a quick PR to fix this issue in the docs. It got merged so it will be updated in the next release of the docs.

1 Like