Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

pagination query result problem.




13 February 2009 at 8:52pm (Last edited: 13 February 2009 10:28pm), Community Member, 192 Posts

I write my query in this way.

function Conn()
       global $db_pandora;
    $record=$db_pandora->query('SELECT * FROM mm_ville');
{ }

$doSet = new DataObjectSet();
foreach($rec as $key)
$record = array(
'Id' => $key['id'],
'Nome' => $key['name'],
'Descrizione' => $this->CutString($key['description'], 100),
'Foto' => $key['filename']
$doSet->push(new ArrayData($record));
return $doSet;

This show me 25 result. Now I need to divide result in 3 page (10 results every page). My problem is that in this way I create 25 page and all 25 results are repeated in all 25 page. Can you help me to solve this problem and to find my error?
I think the problem is link to Count() function that find a big number of elemnts. Thanks!

<% if Conn.MoreThanOnePage %>
<div id="PageNumbers">
<% if Conn.NotLastPage %>
<a class="next" href="$Conn.NextLink" title="View the next page">Next</a>
<% end_if %>
<% if Conn.NotFirstPage %>
<a class="prev" href="$Conn.PrevLink" title="View the previous page">Prev</a>
<% end_if %>
<% control Conn.Pages %>
<% if CurrentBool %>
<% else %>
<a href="$Link" title="View page number $PageNum">$PageNum</a>
<% end_if %>
<% end_control %>
<p>Page $Conn.CurrentPage of $Conn.TotalPages</p>
<% end_if %>