Hide
on 4/9/06

Quite often the question is asked "How can I access XYZ in my controller/view/model etc?". IMO this question rarely needs to be asked ;).

Using the following simple approach should empower you to answer most questions:

  1. Set DEBUG to 2 in your /app/config/core.php file so you can see the executed SQL whilst you are developing, you can set it to 3 to see a dump of the current controller at the foot of the page (might make your page loads a bit cumbersome - especially if you have ajax requests).
  2. Use the Search facility, pay particular attention to the API.
  3. Don't be afraid to look at the cake source code; you may be able to quickly see the answer to your question. DON'T make changes to the code (except perhaps temporary debug code) or you may find that upgrading becomes a 2hour task instead of a 2minute one.
  4. If in doubt stick something like this in your code: [Code]
  5. Don't forget that CakePHP is still PHP :); If you know some data has been set somewhere but you don't know where it is - use what PHP provides such as Get defined vars and search the output on your screen.

If you still don't know where something is after that - think if what you are trying to do is logical, and if you think that it is, it might be worth asking.

on 4/9/06

The singer Beyonce