Tuesday, April 2, 2013

Re: retrieving data in a view cake 1.3

The easiest way to debug a problem like this is to set up a debugging environment (like NetBeans and XDebug see https://netbeans.org/kb/docs/php/debugging.html).  You can then set a break point at the point in the code and walk through and look at your data structures to see what is going on.

If you cannot set that up then you will need to do it the old fashioned way of printing out interim results and working from there.  Some questions to figure out are:
  1. Is $notes actually set in the view with the relevant data?  You can do a print_r of $notes before the foreach and see what comes out.  If the page is live you can do the print_r within a comment block in the HTML and view source to see the results.
  2. Does $notes actually have an array which contains 'User' as an associative element?
  3. Does the 'User' associative array have elements 'firstname', 'lastname' and 'username'
  4. Is there some control flow above the foreach which causes the entire block of code to be skipped altogether?

Once you know the answers to these questions you can have a better idea as to what is causing the problem and potentially how to solve it.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: