|
Posted by Bruno B B Magalhes on 01/08/05 01:36
Hi guys,
currently I have a function in my framework´s mysql driver , that fetch
paginated results... Here it´s:
===============================================================
/*****************************************************
* Fetch paginated results
*****************************************************/
function fetch_paginated($query='',$page=1,$itens=20)
{
$this->query($query.' LIMIT '.(($page*$itens)-$itens).','.$itens);
if($this->num_rows() > 0)
{
while($this->fetch_array())
{
$results[] = $this->row;
}
}
else
{
return null;
}
$this->query($query.' LIMIT 0,'.(($page*$itens)-$itens));
$this->pages_before = ceil($this->num_rows()/$itens);
$this->query($query.' LIMIT '.($page*$itens).',1000000000000000000');
$this->pages_after = ceil($this->num_rows()/$itens);
$this->query($query);
$this->total_pages = ceil($this->num_rows()/$itens);
return $results;
}
===============================================================
My question is: Is there ANY way to speed up this function, or any way
to fetch paginated results quicker? I had a project list, without
pagination, and when I added the pagination function, it slowed down up
to 0.0125 secs. Before it was running at 0.0600 more or less, and now
it´s running at 0.07 to 0.075...
Best Regards,
Bruno B B Magalhães
Navigation:
[Reply to this message]
|