Sunday, May 31, 2009

Why Am I Getting Duplicate Records For My CakePHP View Display

Hi:
I need somebody to help fix a problem of duplicate (even
triplicate) rows for the same record (with same unique ID) from my
table - in my cakephp view displays.

I know the problem is definitely coming from Cake because I can
confirm that the mysql tables don't have the repeated records. Could
it be a pagination bug that I don't know of? here's the code from my
'index' controller and view:

FROM index CONTROLLER:
-----------------------------
function index() {
$this->Jurisdiction->recursive = 0;
$this->set('jurisdictions', $this->paginate());
}


FROM index VIEW
-----------------------------
<div class="jurisdictions index">
<h2><?php __('Jurisdictions');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out
of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<div class="actions">
<ul>
<li><?php echo $html->link(__('New Jurisdiction', true), array
('action'=>'add')); ?></li>
</ul>
</div>
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $paginator->sort('id');?></th>
<th><?php echo $paginator->sort('name');?></th>
<th><?php echo $paginator->sort('city');?></th>
<th><?php echo $paginator->sort('region');?></th>
<th><?php echo $paginator->sort('description');?></th>
<th><?php echo $paginator->sort('auth_level');?></th>
<th><?php echo $paginator->sort('contact_id');?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($jurisdictions as $jurisdiction):
$class = null;
$class = ( ($i % 2) ? " class='altrow'": '' );
$i++;
//if ($i++ % 2 == 0) {
// $class = ' class="altrow"';
//}
?>


Any help would be much appreciated.

-sdarko

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: