Recursive in Cakephp - Explanation

Asked

Viewed 288 times

2

I would like to know, for example, how the recursive cakephp.

$this->Model->recursive=2;

What he does exactly, in practice?

1 answer

2


According to the documentation, the property recursive defines how deep Cakephp should go to fetch the records associated with a data model using methods find and/or read.

Imagine that your application characterizes Groups which belong to a domain that has several Users which in turn has several Articles.

You can set the property recursive with different values with based on the amount of data you want to return from a call, by example $this->Group->find():

  • -1 Search for data only from Group, junction-free.
  • 0 Search for data from Group and of his domain.
  • 1 Searching for a Group, your domain and their Users associates.
  • 2 Searching for a Group, your domain, their Users associates and the articles associates of Users.

The standard is 1. The recommended recursion level is -1. That avoid returning related data that is unnecessary or even undesirable

See also the article Recovering Your Data in English of blog cakephp.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.