CakePHP 2.0 Read Recursive

Something that caught me out when I was using CakePHP at first

This is something that caught me out several times when I was new to CakePHP, so I thought I would post it here in case you are in a similar situation.

Basically I was hitting issues that when I was viewing the variables available to a view (using the CakePHP Debug Toolbar) were I was noticing that I was bringing back far more information than I needed (and occasionally, not enough)

Bringing back too much information is never a good thing, it is inefficient and a possible security leak.

The reason for this is that in CakePHP the Read, Find or FindAll takes in a value called Recursive.

To set the level of recursion you do something similar to the following;

$this->Model->recursive = 1

There are 4 settings, which can be read about in detail in the CakePHP Book, but basically you can use this to make Read, Find or FindAll not perform JOINS (or perform more of them!).

Be sure that your selections only ever return the data they need to and no more.

Recent posts View all

Productivity

5 ways to speed up your software development

I love feeling like I am speeding through development tasks, here are five things that can help speed up your software development

Accessibility SEO

The main reasons why we shouldn't use click here as link text

There are many reasons why we shouldn't use click here or similar as link text, let's go through them