In brief:

A. The method is Controller::paginate() and the returned set of
records are passed to the view.

B. Controller::$params['requested'] is set when the action is called
using requestAction. It offers a method of returning data without
requiring that a view is rendered as well.

C. No, $posts is only a paginated set of records. The view would be /
app/views/posts/index.ctp

D. Controller::set() is the method used to pass data to the view.
Essentially, writing compact('posts') is exactly the same as writing
array('posts' => $posts). More on compact() can be found at 
http://php.net/compact

On Jul 7, 3:49 pm, heli007 <[email protected]> wrote:
>    1.  <?php
>    2. class PostsController extends AppController {
>    3. ...
>    4. function index() {
>    5. $posts = $this->paginate();
>    6. if (isset($this->params['requested'])) {
>    7. return $posts;
>    8. } else {
>    9. $this->set(compact('posts'));
>   10. }
>   11. }
>   12. }
>   13. ?>
>
> those codes are from 3.9.3 Elements part of the doc,some Q:
> A)  $posts = $this->paginate(); ----    posts is view or action?
> paginate() is a method of PostsController?
> B)$this->params['requested']---- mean?
> C)return $posts---posts is the view?
> D)$this->set(compact('posts'));----mean?
>  what kind of method compacts() is ?
> posts is the view?
>
> thx
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to