I have news_item table with 176541 rows. This is result witch i run in phpMyAdmin
But i run paging in backend with news_item, i can't get result return. It run always (i set timeout 3000). This is my indexAction (backend/news/index)
<?php
function indexAction(){
$currentPage = 1;
$myUri = null;
$menu_id = null;
$keyword = null;
$conditions = null;
if($this->request->get("page")):
$currentPage = (int)$this->request->get("page");
endif;
//menu item
$item = Menu::find(array("conditions" => "type in (2,8,9)",
"order" => "sort ASC",
"columns" => "id, title, sort, parents"));
$recursive = new Recursive($item->toArray());
$menu = $recursive->buildArray(0);
$this->view->setVar("menu",$menu);
//SELECT ITEM IN ONE CATEGORY
$this->view->setVar("cid", $menu_id);
if($this->request->get("cid")){
$menu_id = $this->request->get("cid");
$conditions .= ' menu_id = '.(int)$menu_id;
$this->view->setVar("cid", $menu_id);
}
//FOR SEARCH
if($this->request->get("keyword")){
$keyword = $this->request->get("keyword");
$conditions .= ' title LIKE \'%'.(string)$keyword."%'";
$this->view->setVar("keyword", $keyword);
}
$items = News::find(array(
"conditions" => $conditions,
"order" => "id DESC",
"columns" => "id,title,created,sort,menu_id,special,status,featured"
));
$paginator = new \Phalcon\Paginator\Adapter\Model(
array(
"data" => $items,
"limit"=> 10,
"page" => $currentPage
)
);
// Get the paginated results
$page = $paginator->getPaginate();
$myUri = '&cid='.$menu_id.'&keyword='.$keyword;
$this->view->setVar("myUri", $myUri);
$this->view->setVar("page",$page);
}
?>
Certainly, my action run with several hundred rows. My friend has same problem, he used CI framwork is ok.
Test:
- Localhost / Win7 / RAM 2G
- Xampp: PHP Version 5.6.8 / Server version: 5.6.24
Could you please help me :( Thanks Phalcon so much.