Saturday, November 23, 2013

Re: Cake PHP displaying values from paginate() in view - basic question

In CakePHP blog tutorial Post is referring to a model (database table "posts") holding all blog posts (articles).
So instad $u['Post']['username'] use $u['User']['username'] in your view file.

Regarding paginate vs find('all'), see
http://book.cakephp.org/2.0/en/core-libraries/components/pagination.html
http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#find-all


On Thursday, November 21, 2013 10:40:56 PM UTC+1, Art Sir wrote:

 just started my phpcake adventure. I got a migraine from all this MVC.

//Controller file

class UsersController extends AppController {          public function index() {          $this->User->recursive = 0;          $this->set('users', $this->paginate());      }  }

//view file, so i'm passing in $users into the view file

<table>      <tr>          <th>Id</th>          <th>Name</th>          <th>Password</th>      </tr>        <?php foreach ($users as $u): ?>      <tr>          <td><?php echo $u['User']['id']; ?></td>          <td><?php echo $u['Post']['username']; ?></td>          <td> <?php echo $u['Post']['password']; ?></td>      </tr>  </table>

In my sql, my columns are id,username and password

$u['what am i suppose to put in here'  ]

In the cake php tutorial i used Post but i'm wondering what the Post is referring to Post method? or Post from the controller name? And whats the difference between paginate and $this->set('users', $this->Post->find('all'));

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: