2013-10-14 2 views
2

Je suis aller chercher tous mes utilisateurs et les montrer dans la liste et la pagination dans CakePhp. Mais pourquoi il me donne
Erreur: Une erreur interne s'est produite. et sous la pile Trace la lignepagination cakephp dit Erreur: Une erreur interne s'est produite

$data = $this->Paginator->paginate('User'); est mis en surbrillance.

UserhomeController.php

<?php 

App::uses('AppController', 'Controller'); 

class UserhomeController extends AppController { 

    public $components = array('Paginator', 'RequestHandler'); 
    public $helpers = array('Js', 'Paginator'); 
    public $paginate = array(
     'fields' => array('User.id', 'User.email'), 
     'limit' => 25, 
     'order' => array(
      'User.email' => 'asc' 
     ) 
    ); 

    public function index() { 
     $this->Paginator->settings = $this->paginate; 

     // similar to findAll(), but fetches paged results 
     $data = $this->Paginator->paginate('User'); 
     $this->set('user', $data); 
    } 

} 

UserHome/index.ctp

<?php 
    $this->Paginator->options(array(
     'update' => '#content', 
     'evalScripts' => true 
    )); 
    ?> 
    <div class="container bottom_padding background_color_E8E3D7 height_full padding_top box_shadow"> 
     <table class="table table-striped background_color_eee"> 
      <!-- Here is where we loop through our $users array, printing out post info --> 

      <?php foreach ($data as $user): ?> 
       <tr> 
        <td><?php echo $user['User']['id']; ?></td> 
        <td> 
         <?php echo $this->Html->link($user['User']['title'], array('controller' => 'users', 'action' => 'view', $user['User']['id'])); 
         ?> 
        </td> 
        <td><?php echo $user['User']['email']; ?></td> 
       </tr> 
      <?php endforeach; ?> 
      <?php unset($user); ?> 
     </table> 
     <ul class="pagination"> 
      <?php 
      echo $this->Paginator->prev(__('<<'), array('tag' => 'li'), null, array('tag' => 'li', 'class' => 'disabled', 'disabledTag' => 'a')); 
      echo $this->Paginator->numbers(array('separator' => '', 'currentTag' => 'a', 'currentClass' => 'active', 'tag' => 'li', 'first' => 1)); 
      echo $this->Paginator->next(__('>>'), array('tag' => 'li', 'currentClass' => 'disabled'), null, array('tag' => 'li', 'class' => 'disabled', 'disabledTag' => 'a')); 
      ?> 
     </ul> 
     <br/> 
     <?php 
     echo $this->Paginator->counter(
       'Page {:page} of {:pages}, showing {:current} records out of 
     {:count} total, starting on record {:start}, ending on {:end}' 
     ); 
     ?> 

    </div> 
    <?php echo $this->Js->writeBuffer(); ?> 
+0

Vous faites référence à un modèle du contrôleur ne sait rien environ – AD7six

+0

désolé pourriez-vous s'il vous plaît expliquer. où pointez-vous l'erreur? –

Répondre

10

Ajouter public $uses = array('User'); à votre contrôleur

+2

Merci. Le gâteau devrait vous donner un meilleur message d'erreur pour ceci. – Jonathan

-1
$data = $this->paginate('User'); 
+0

êtes-vous sûr de ce problème va résoudre ?? cela ne fonctionnera pas –

Questions connexes