Comments on “CakePHP: Recursive Finds”http://robwilkerson.org/2009/01/03/cakephp-recursive-finds/feed2010-02-04T11:01:29-04:00ChyrpCakePHP: Recursive Findstag:robwilkerson.org,2010-02-04:/id/162//comment_160442010-02-04T11:01:29-04:002010-02-04T11:01:29-04:00Chris C2http://www.ipcoders.co.uk
<p><span class="caps">OMG</span>! I agree the docs <span class="caps">ARE</span> confusing – In most cases the examples that explain the point in questions is very basic – and for a begginner this does not help.</p>
<p>Take the example of recursive finds, the example isnt that clear, well I guess it is if you read:</p>
<p>http://book.cakephp.org/view/439/recursive</p>
<p>however what isnt that clear is specifically what tables does the example use, but more importantly their relationships.</p> CakePHP: Recursive Findstag:robwilkerson.org,2009-06-12:/id/162//comment_92902009-06-12T15:31:12-04:002009-06-12T15:31:12-04:00Chrishttp://visual-a.com
<p>Adman, daniel h.,</p>
<p>Get over it. The point is that even after all the time inbetween the last post here and now, if a diligent programmer is reading the manual they are introduced to AppModel->find() in section 3.731 where the “documentation” of its options is as follows:</p>
<p>[…]<br />
‘recursive’ => 1, //int<br />
[…]<br />
‘limit’ => n, //int<br />
‘page’ => n, //int<br />
[…]</p>
<p>The diligent programmer is made to wait until 3.7.8.6 to have ‘recursive’ explained to him or her, and even then, it’s mashed together with all AppModel options documentation. Regardless of how sensitive you are, this is not good documentation. There should either be better organization of section 3.7.8 or there should be links throughout all of section 3.7 to its specific definitions.</p>
<p>While artiescie’s point is obviously correct, that documenters have difficult jobs, adman’s assertion that we should all stop being “just too lazy [and] dig deeper” completely invalidates all of the documenter’s hard work in making the docs accessible in the first place.</p> CakePHP: Recursive Findstag:robwilkerson.org,2009-02-07:/id/162//comment_56952009-02-07T13:41:18-04:002009-02-07T13:41:18-04:00artiescie
<p>CakePHP as a team is going to be sensitive about the bad docs slam. But how do bad docs happen, and how do they get fixed? </p>
<p>The documenter usually has one of the most impossible jobs. He is expected to deliver the docs at the same time as the release. As if it was a construction project.</p>
<p>He might be able to pull it off: – IF the big boss said the developers had to deliver up to date, working examples of every “use case”. OR failing that – IF the developer had some authority over developer time to force them to show the code working. OR failing that – IF there were effective standards that automated testing showed real world functionality and the Developer could put them together. OR failing that – IF there existed at least good coverage tests, <span class="caps">AND</span> they were up to date, <span class="caps">AND</span> the developer had enough time to go through them and put together a real example. </p>
<p>Exercise for the reader: drill down in the CakePHP <span class="caps">WIKI</span> for code, looks like it’s there. But wait… when I click on testsuites I see an empty page with “More info will follow”. I’m getting the picture ;-)</p>
<p>Again, Let’s not point fingers, work needs to be done. What’s been done was the likely near the best possible at the time. Improvement is needed.</p> CakePHP: Recursive Findstag:robwilkerson.org,2009-01-21:/id/162//comment_55552009-01-21T16:10:36-04:002009-01-21T16:10:36-04:00beemanhttp://bvirtual.nl/
<p>Good post Rob, I totally agree with you. As a newcomer to CakePHP it is sometimes hard to find the right way to do the things you want. It would be helpful to have more examples. </p>
<p>I’m planning on writing some howto’s in the future, when I’m more confident about my CakePHP-skills… :)</p> CakePHP: Recursive Findstag:robwilkerson.org,2009-01-09:/id/162//comment_51562009-01-09T15:57:58-04:002009-01-09T15:57:58-04:00Rob Wilkersonhttp://robwilkerson.org
<p>@daniel: No, not yet. I’m still working to acquire a decent comfort level with Cake. As I mentioned in the last paragraph…</p>
<blockquote>
<p>As I get more familiar with CakePHP, more confident that I know what I’m doing and that I’m doing things the right (read: Cake) way, I’ll do my part to help clarify the documentation where I believe it necessary…</p>
</blockquote> CakePHP: Recursive Findstag:robwilkerson.org,2009-01-09:/id/162//comment_51492009-01-09T14:36:53-04:002009-01-09T14:36:53-04:00Daniel H.
<p>Since you obviously think that the documentation on “recursive” might be misleading … I hope you gave it a shot and tried to improve it?!</p> CakePHP: Recursive Findstag:robwilkerson.org,2009-01-04:/id/162//comment_45912009-01-04T11:12:29-04:002009-01-04T11:10:18-04:00Rob Wilkersonhttp://robwilkerson.org
<p>Seriously? That’s awfully sensitive.</p>
<p>Look, this post was about a mistake I made after reading the docs, not a slam-the-docs post. The post outlines:</p>
<p>- What I read</p>
<p>- What I thought/assumed/understood</p>
<p>- Why I was wrong</p>
<p>Others new to Cake might make the same mistake and maybe this will help. Or maybe not and that’s okay too.</p>
<p>You’re right about my use of the term “misleading”. It was a poor (and inaccurate) choice of words and I’ve adjusted the post accordingly. That said, I stand by my statements that the documentation can be improved and even added one. Here’s why I think that (using this specific scenario):</p>
<p>- I was looking to retrieve information from my model</p>
<p>- I looked in what I considered (and still consider) to be the obvious place, the section entitled <em>Retrieving Your Data</em>.</p>
<p>- I saw an ambiguity (yes, I understand that the type is documented there, but I also explained what lead me to incorrectly read it as a boolean).</p>
<p>- I saw no additional information about the ‘recursive’ parameter on that page nor did I see any links to other pages that might contain related information.</p>
<p>- I made an assumption and tried it. That assumption turned out to be wrong, so I continued looking via other support channels.</p>
<p>Being new to Cake – I’m working on my first Cake project – I don’t want to immediately go digging through the code or the documentation for an <span class="caps">API</span> that I’m not decently versed in just yet so I looked elsewhere. Ultimately I found the answer. Had I not, I certainly would have dug around in the code or searched a little harder, but I was fortunate enough to get my question answered before doing so.</p>
<p>Saying that the docs aren’t perfect isn’t a knock on the docs or the fine folks who put in the time to create/update them. It’s a simple statement of where I think there’s room for improvement and supporting that with <em>how</em> I think that they can be improved. </p>
<p>Feel free to disagree with that in a reasonable manner, but don’t resort to ad hominem arguments about my laziness.</p> CakePHP: Recursive Findstag:robwilkerson.org,2009-01-03:/id/162//comment_45162009-01-03T17:38:48-04:002009-01-03T17:38:48-04:00ADmad
<p>I have no problems with you thinking it to be boolean. People make mistakes. What i didn’t appreciate was you stating like “..provides very little information about the recursive parameter..”, “..but it can be misleading to new CakePHP developers..”.</p>
<p>As i pointed out all available sources regarding the recursive property clearly state its an integer. You were just too lazy to dig deeper and conveniently blamed the doc to be ambigious/misleading.</p> CakePHP: Recursive Findstag:robwilkerson.org,2009-01-03:/id/162//comment_45142009-01-03T17:22:54-04:002009-01-03T17:22:54-04:00Rob Wilkersonhttp://robwilkerson.org
<p>@Kevin: Thanks. I’m aware of that behavior, but am still trying to see what the “basics” will do for me before digging into some of the more surgical capabilities.</p>
<p>@ADmad: Easy there, sailor, there’s no need to get your knickers in a twist. I said I read it wrong and I explained <em>why</em> I read it wrong. I wrote about it simply because I thought it might be something that others new to Cake may read wrong as well. </p>
<p>Because the only examples I’d seen used a “1”, it wasn’t unreasonable in my mind to think of it as a boolean. That said, I clearly didn’t scour the docs for every mention of “recursive” and I should have looked a bit more. I’m still learning the docs, too.</p> CakePHP: Recursive Findstag:robwilkerson.org,2009-01-03:/id/162//comment_45062009-01-03T15:36:14-04:002009-01-03T15:36:14-04:00ADmad
<p>Manual:<br />
http://book.cakephp.org/view/71/Model-Attributes#recursive-439</p>
<p>Depth: -1, 0, 1, 2<br />
(All so ambiguous let me just assume it to be boolean) </p> CakePHP: Recursive Findstag:robwilkerson.org,2009-01-03:/id/162//comment_45032009-01-03T15:32:09-04:002009-01-03T15:32:09-04:00ADmad
<p>The manual/api/code are pretty clear about recursive being integer. You just assumed it to be boolean.</p>
<p>Manual:<br />
‘recursive’ => 1, //int (does int mean integer? No its boolean)</p>
<p><span class="caps">API</span>:<br />
http://api.cakephp.org/class_model.html#e60758f27fa8486a063b8cc424bad741<br />
Eg: find(‘all’, array( ‘conditions’ => array(‘name’ => ‘Thomas Anderson’), ‘fields’ => array(‘name’, ‘email’), ‘order’ => ‘field3 <span class="caps">DESC</span>’, ‘recursive’ => 2, ‘group’ => ‘type’));</p>
<p>‘recursive’ => 2 (ah even 2 is boolean)</p>
<p>Code:<br />
http://api.cakephp.org/libs_2model_2model_8php-source.html#l00253<br />
@var integer (crap.. again that’s boolean)</p> CakePHP: Recursive Findstag:robwilkerson.org,2009-01-03:/id/162//comment_45012009-01-03T15:11:35-04:002009-01-03T15:11:35-04:00Kevinhttp://dexterthedragon.com
<p>You should also look into the containable behavior http://book.cakephp.org/view/474/Containable<br />
You specify which models you want data back from and it handles setting the recursive level itself.</p>