Cakephpdocs 45

Categorymodel attribute (property) - recursive
Code Examplesfunction index() { $this->Post->recursive = 0; $this->set('posts', $this->paginate()); } The recursive attribute tells the model how far to look when pulling those associated records. If users were to have an association with another table and the recursive attribute were set to a value greater than 1, then the model would pull not only the associated user records but their associated tables’ records as well. In the Index action, the recursive attribute is set to zero, which means that beyond the initial level of associations, Cake will ignore other records. The following table outlines the possible recursive values and their results. Possible Recursive Values Value Result –1 Returns only the current model and ignores all associations 0 Returns the current model plus its owner(s) 1 Returns the current model and its owner plus their associated models 2 Returns the current model, its owner, their associated models, and the associated models of any associations
Test Code
Links
Remarks
Cancel