當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Adapter\Model類代碼示例

本文整理匯總了PHP中Phalcon\Paginator\Adapter\Model的典型用法代碼示例。如果您正苦於以下問題:PHP Model類的具體用法?PHP Model怎麽用?PHP Model使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Model類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: paging

 public function paging($data)
 {
     $currentPage = (int) $_GET['page'];
     $paginator = new PaginatorModel(array("data" => $data, "limit" => 10, "page" => $currentPage));
     $page = $paginator->getPaginate();
     return $page;
 }
開發者ID:xw716825,項目名稱:xw,代碼行數:7,代碼來源:ModelBase.php

示例2: indexAction

 public function indexAction()
 {
     $this->tag->setTitle('Quản lý bài viết');
     $news = News::find(array('order' => 'id DESC'));
     $currentPage = $this->request->getQuery("page", "int") > 0 ? $this->request->getQuery("page", "int") : 1;
     // Create a Model paginator, show 10 rows by page starting from $currentPage
     $paginator = new PaginatorModel(array("data" => $news, "limit" => 10, "page" => $currentPage));
     // Get the paginated results
     $page = $paginator->getPaginate();
     $this->view->setVar('page', $page);
     // Change active
     $params = $this->request->getPost();
     $id = isset($params['id']) ? $params['id'] : '';
     $active = isset($params['active']) ? $params['active'] : '';
     if ($active == 1) {
         $active = 2;
     } else {
         if ($active == 2) {
             $active = 1;
         }
     }
     if ($id != null) {
         $news = News::findFirst($id);
         $news->active = $active;
         $news->save();
     }
 }
開發者ID:JosTrucD,項目名稱:phalcon-news,代碼行數:27,代碼來源:NewsController.php

示例3: indexAction

 public function indexAction($page = 1)
 {
     $parameters["order"] = "gid desc";
     $users = Groups::find($parameters);
     $paginator = new Model(array('data' => $users, 'limit' => 20, 'page' => $page));
     $this->view->page = $paginator->getPaginate();
 }
開發者ID:zhangkg,項目名稱:phalcon_manage,代碼行數:7,代碼來源:RolesController.php

示例4: listAction

 public function listAction()
 {
     $params = $this->request->getQuery();
     if ($params['_url'] != null) {
         $string = ltrim($params['_url'], '/danh-muc');
     }
     $array = explode('-', $string);
     $id = $array[0];
     // Get name category
     $category = Category::findFirstById($id);
     $this->tag->setTitle($category->name);
     // Get list category of id
     if ($id != '' && $id > 0) {
         // The data set to paginate
         $news = News::find(array('active = 1 AND category =' . $id, 'order' => 'id DESC'));
         $currentPage = (int) $_GET["page"];
         // Create a Model paginator, show 10 rows by page starting from $currentPage
         $paginator = new PaginatorModel(array("data" => $news, "limit" => 13, "page" => $currentPage));
         // Get the paginated results
         $page = $paginator->getPaginate();
         $this->view->setVar('page', $page);
         $this->view->setVar('category', $category);
     } else {
         $this->response->redirect('error');
     }
 }
開發者ID:JosTrucD,項目名稱:phalcon-news,代碼行數:26,代碼來源:IndexController.php

示例5: getPage

 public function getPage($config = array())
 {
     if (isset($config['data'])) {
         $cname = isset($config['cname']) ? $config['where'] : $this->dispatcher->getControllerName();
         $limit = isset($config['limit']) ? $config['limit'] : 15;
         $getUrl = isset($config['getUrl']) ? $config['getUrl'] : '';
         // Page
         $page = $this->request->getQuery('page', 'int');
         $paginator = new PaginatorModel(array('data' => $config['data'], 'limit' => $limit, 'page' => $page));
         $Page = $paginator->getPaginate();
         // Page Html
         $Lang = $this->inc->getLang('inc');
         $html = '';
         if (empty($page) || $page == 1) {
             $html .= '<span>' . $Lang->_('inc_page_first') . '</span>';
             $html .= '<span>' . $Lang->_('inc_page_before') . '</span>';
         } else {
             $html .= '<a href="' . $this->inc->BaseUrl($cname) . '?page=1' . $getUrl . '">' . $Lang->_('inc_page_first') . '</a>';
             $html .= '<a href="' . $this->inc->BaseUrl($cname) . '?page=' . $Page->before . $getUrl . '">' . $Lang->_('inc_page_before') . '</a>';
         }
         if ($page == $Page->last) {
             $html .= '<span>' . $Lang->_('inc_page_next') . '</span>';
             $html .= '<span>' . $Lang->_('inc_page_last') . '</span>';
         } else {
             $html .= '<a href="' . $this->inc->BaseUrl($cname) . '?page=' . $Page->next . $getUrl . '">' . $Lang->_('inc_page_next') . '</a>';
             $html .= '<a href="' . $this->inc->BaseUrl($cname) . '?page=' . $Page->last . $getUrl . '">' . $Lang->_('inc_page_last') . '</a>';
         }
         $html .= ' Page : ' . $Page->current . '/' . $Page->total_pages;
         $Page->PageHtml = $html;
         return $Page;
     } else {
         return FALSE;
     }
 }
開發者ID:Robert-Xie,項目名稱:phalcon-webmis,代碼行數:34,代碼來源:Inc.php

示例6: indexAction

 /**
  * Default action, shows the search form
  */
 public function indexAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = \Phalcon\Mvc\Model\Criteria::fromInput($this->di, "\\Models\\Roles", $_POST);
         $query->order("id ASC, name ASC");
         $this->persistent->searchParams = $query->getParams();
         if (!\Helpers\Arr::is_array_empty($this->persistent->searchParams)) {
             $models = \Models\Roles::find($this->persistent->searchParams);
         }
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if (!$numberPage or $numberPage <= 0) {
             $numberPage = 1;
         }
         if ($numberPage > 1 and !\Helpers\Arr::is_array_empty($this->persistent->searchParams)) {
             $models = \Models\Roles::find($this->persistent->searchParams);
         } else {
             //$models = \Models\Roles::query()->order("id ASC, name ASC")->execute();
             $models = \Models\Roles::find();
             $this->persistent->searchParams = null;
         }
     }
     if (count($models) == 0) {
         $this->flashSession->notice("Не найдено");
         $this->persistent->searchParams = null;
     }
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $models, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
     //$this->view->setVar('searchparams', $this->persistent->searchParams);
     //$this->view->setVar('numpage', $numberPage);
 }
開發者ID:devsnippet,項目名稱:city_site,代碼行數:36,代碼來源:RolesController.php

示例7: indexAction

 /**
  * user list
  */
 public function indexAction()
 {
     $page = $this->request->getQuery('page', 'int', 1);
     $users = Users::find();
     $paginator = new Model(array('data' => $users, 'limit' => 20, 'page' => $page));
     $this->view->page = $paginator->getPaginate();
 }
開發者ID:liushuai,項目名稱:phalcon_manage,代碼行數:10,代碼來源:UsersController.php

示例8: articleAction

 public function articleAction()
 {
     $posts = Post::find(['type = "post" AND id_web = "' . $this->auth->id_web . '" order by id desc']);
     $paginator = new PaginatorModel(array("data" => $posts, "limit" => $this->params->limit, "page" => $this->params->page));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
 }
開發者ID:ametsuramet,項目名稱:eazy-dashboard,代碼行數:7,代碼來源:PostController.php

示例9: searchAction

 /**
  * Searches for operadora
  */
 public function searchAction($yacimientoId = null)
 {
     parent::importarJsTable();
     $numberPage = 1;
     if ($yacimientoId != null) {
         $operadora = Operadora::find(array('operadora_yacimientoId=:yacimiento_id:', 'bind' => array('yacimiento_id' => $yacimientoId)));
     } else {
         if ($this->request->isPost()) {
             $query = Criteria::fromInput($this->di, "Operadora", $_POST);
             $this->persistent->parameters = $query->getParams();
         } else {
             $numberPage = $this->request->getQuery("page", "int");
         }
         $parameters = $this->persistent->parameters;
         if (!is_array($parameters)) {
             $parameters = array();
         }
         $parameters["order"] = "operadora_id";
         $operadora = Operadora::find($parameters);
     }
     if (count($operadora) == 0) {
         $this->flash->notice("No se han encontrado resultados");
         return $this->dispatcher->forward(array("controller" => "operadora", "action" => "index"));
     }
     $paginator = new Paginator(array("data" => $operadora, "limit" => 25, "page" => $numberPage));
     $this->view->page = $paginator->getPaginate();
 }
開發者ID:munozdaniel,項目名稱:sya,代碼行數:30,代碼來源:OperadoraController.php

示例10: indexAction

 /**
  * Index action
  */
 public function indexAction()
 {
     $numberPage = $this->request->getQuery("page", "int", 1);
     $comments = Comments::query()->order("submitted DESC")->execute();
     $paginator = new Paginator(array("data" => $comments, "limit" => 10, "page" => $numberPage));
     $this->view->page = $paginator->getPaginate();
 }
開發者ID:gn0st1k4m,項目名稱:phalconBlog,代碼行數:10,代碼來源:CommentsController.php

示例11: searchAction

 /**
  * Searches for usuario
  */
 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "Usuario", $_POST);
         $this->persistent->parameters = $query->getParams();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
     }
     $parameters = $this->persistent->parameters;
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $parameters["order"] = "idusuario";
     $usuario = Usuario::find($parameters);
     if (count($usuario) == 0) {
         $this->flash->notice("The search did not find any usuario");
         return $this->dispatcher->forward(array("controller" => "usuario", "action" => "index"));
     }
     $barcode = new Barcode();
     echo "<style>";
     echo $barcode->getCssStyle();
     echo "</style>";
     //echo $barcode->code39("AB20150wewesdsd");
     $this->view->setVar("barcode", $barcode);
     $paginator = new Paginator(array("data" => $usuario, "limit" => 10, "page" => $numberPage));
     $this->view->page = $paginator->getPaginate();
 }
開發者ID:Jonhathan-Rodas,項目名稱:ranchogrande,代碼行數:31,代碼來源:UsuarioController.php

示例12: indexAction

	public function indexAction($categoryID = 0)
	{
		$this->setTitle("Список элементов");
		$this->setCategoryTitleSmall($categoryID);
		
		$this->view->addUrl = $this->di->get('url')->get(array(
			'for' => 'new_element', 
			'categoryID' => $categoryID
		));
		
		$elements = Elements::find([
			"categoryID = :categoryID:",
			"bind" 		=> ["categoryID" => $categoryID],
			"bindTypes" => ["categoryID" => Column::BIND_PARAM_INT],
			"order" 	=> "created desc"
		]);

// ПАГИНАЦИЯ ???
        $paginator = new Paginator(array(
            "data"  => $elements,
            "limit" => 10,
            "page"  => $this->request->getQuery("page", "int") ?: 1
        ));

        $this->view->page = $paginator->getPaginate();
		$this->view->elements = $elements;		
	}
開發者ID:Kefir92,項目名稱:home-bookkeeping,代碼行數:27,代碼來源:ElementsController.php

示例13: paging

 /**
  * ページングを実行する
  * 指定がなければ最初(=1)のページ @param $page
  * @param $count
  * @param $list
  * @return $this
  */
 public function paging($list, $count, $page = 1)
 {
     $pagenator = new Paginator(['data' => $list, 'limit' => $count, 'page' => $page]);
     $this->pagenate = $pagenator;
     $this->page = $pagenator->getPaginate();
     return $this;
 }
開發者ID:muramoya,項目名稱:kotori,代碼行數:14,代碼來源:ResourcesList.php

示例14: searchAction

 /**
  * Searches for equipopozo
  */
 public function searchAction($yacimientoId = null)
 {
     parent::importarJsTable();
     $numberPage = 1;
     if ($yacimientoId != null) {
         $equipopozo = Equipopozo::find(array('equipoPozo_yacimientoId=:yacimiento_id:', 'bind' => array('yacimiento_id' => $yacimientoId)));
     } else {
         if ($this->request->isPost()) {
             //$query = parent::fromInput($this->di, 'Equipopozo', $this->request->getPost());
             $query = Criteria::fromInput($this->di, "Equipopozo", $_POST);
             $this->persistent->parameters = $query->getParams();
         } else {
             $numberPage = $this->request->getQuery("page", "int");
         }
         $parameters = $this->persistent->parameters;
         if (!is_array($parameters)) {
             $parameters = array();
         }
         $parameters["order"] = "equipoPozo_id";
         $equipopozo = Equipopozo::find($parameters);
     }
     if (count($equipopozo) == 0) {
         $this->flash->notice("No se encontraron resultados en la busqueda");
         return $this->dispatcher->forward(array("controller" => "equipopozo", "action" => "index"));
     }
     $paginator = new Paginator(array("data" => $equipopozo, "limit" => 25, "page" => $numberPage));
     $this->view->page = $paginator->getPaginate();
 }
開發者ID:munozdaniel,項目名稱:sya,代碼行數:31,代碼來源:EquipopozoController.php

示例15: indexAction

 public function indexAction()
 {
     $nowurl = $this->request->getURI();
     $type_list = $this->_getBusTypeList();
     $this->view->type_list = $type_list;
     $this->view->url = $nowurl;
     $project_type = '';
     $project_grow_up = '';
     $is_type_belongs = false;
     $numberPage = 1;
     if ($this->request->isGet()) {
         $query = Criteria::fromInput($this->di, "DtbProduct", $_GET);
     } else {
         $numberPage = $this->request->getQuery("page", "int");
     }
     $this->persistent->parameters = $query->getParams();
     $parameters = $this->persistent->parameters;
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $parameters["order"] = "product_id";
     $dtb_product = DtbProduct::find($parameters);
     if (count($dtb_product) == 0) {
         $this->flash->notice("The search did not find any dtb_product");
     }
     $paginator = new Paginator(array("data" => $dtb_product, "limit" => $this->config->application->page_size, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $page_split = $this->_split_page($page->current, $page->total_pages);
     $this->view->page_split = $page_split;
     //$this->view->disable();
     $this->view->page = $page;
 }
開發者ID:alexz202,項目名稱:goldenlight,代碼行數:32,代碼來源:RaiseProductController.php


注:本文中的Phalcon\Paginator\Adapter\Model類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。