public function userlist() { header("content-type:text/html;charset=utf-8"); import('ORG.Util.Page'); // 导入分页类 $users = new Model('users'); $count = $users->count(); $Page = new Page($count, 10); $show = $Page->show(); $rs = $users->limit($Page->firstRow . ',' . $Page->listRows)->select(); $this->assign('rs', $rs); $this->assign('show', $show); $this->display(); }
/** * Get Results by Page * * @param int $page * @param int $limit * @param array $with * @return StdClass Object with $items and $totalItems for pagination */ public function getByPage($page = 1, $limit = 30, $with = array()) { $result = new \StdClass(); $result->page = $page; $result->totalPage = 0; $result->limit = $limit; $result->totalItems = 0; $result->items = array(); $query = $this->make($with); $model = $query->skip($limit * ($page - 1))->take($limit)->get(); $result->totalItems = $this->model->count(); $result->items = $model->all(); return $result; }
function classList() { header('content-type:text/html;charset=utf8'); import('ORG.Util.Page'); // $cl = new Model('classify'); $count = $cl->count(); $Page = new Page($count, 20); $show = $Page->show(); $rs = $cl->limit($Page->firstRow . ',' . $Page->listRows)->where("fId=1")->select(); foreach ($rs as $key => $val) { $str .= "<tr>"; $str .= "<th align='center' width='10'>" . $val["cName"] . "</th>"; $str .= "<th width=‘10%’>"; $str .= "<a href='__URL__/delClass/cId/" . $val["cId"] . "'>删除</a> |"; $str .= "<a href='__URL__/updClass/cId/" . $val["cId"] . "/cName/" . $val["cName"] . "'>修改</a> |"; $str .= "<a href='__URL__/addSon/cId/" . $val["cId"] . "/cName/" . $val["cName"] . "'>添加子类型</a>"; $str .= "</th>"; $str .= "<th width=‘10%’>"; $str .= "<table cellpadding='0' border='0' cellspacing='0'>"; $sql_1 = "select * from tp_classify where fId='{$val["cId"]}'"; $rs_1 = $cl->query($sql_1); foreach ($rs_1 as $key_1 => $val_1) { $str .= "<tr>"; $str .= "<th width='20%'>" . $val_1["cName"] . "</th>"; $str .= "<th width='20%'spellcheck='0'>"; $str .= "<a href='delClass/cId/" . $val_1["cId"] . "'>删除</a> |"; $str .= "<a href='updClass/cId/" . $val_1["cId"] . "'>修改</a> |"; $str .= "</tr>"; } $str .= "</table>"; $str .= "</th>"; $str .= "</tr>"; } $this->assign('str', $str); $this->assign('show', $show); $this->display(); }
public function type_index() { $model = new Model('kefu_type'); $count = $model->count(); $this->assign('count', $count); $type_list = $model->order('sort_order asc ')->select(); $this->assign('type_list', $type_list); $this->display(); }
public function count($args = "") { //设置表关联 $this->setJoinTable(); $this->init(); return parent::count($args); }
public function count($args = "") { $this->setJoinTable(); return parent::count($args); }
/** * Count current result * @return integer */ public function dtCount() { return $this->dtModel->count(); }
/** * Recursively render this view. */ public function recursiveRender() { // get data source if (!$this->source) { // force grid sorting implemented in Grid_Advanced if ($this->owner instanceof Grid_Advanced) { $this->owner->getIterator(); } // set data source for Paginator if ($this->owner->model) { $this->setSource($this->owner->model); } elseif ($this->owner->dq) { $this->setSource($this->owner->dq); } else { throw $this->exception('Unable to find source for Paginator'); } } // calculate found rows if ($this->source instanceof DB_dsql) { $this->source->preexec(); $this->found_rows = $this->source->foundRows(); } elseif ($this->source instanceof Model) { $this->found_rows = (int) $this->source->count(); } else { $this->found_rows = count($this->source); } // calculate current page and total pages $this->cur_page = (int) floor($this->skip / $this->ipp) + 1; $this->total_pages = (int) ceil($this->found_rows / $this->ipp); if ($this->cur_page > $this->total_pages || $this->cur_page == 1 && $this->skip != 0) { $this->cur_page = 1; if ($this->memorize) { $this->memorize('skip', $this->skip = 0); } if ($this->source instanceof DB_dsql) { $this->source->limit($this->ipp, $this->skip); $this->source->rewind(); // re-execute the query } elseif ($this->source instanceof Model) { $this->source->setLimit($this->ipp, $this->skip); } else { // Imants: not sure if this is correct, but it was like this before $this->source->setLimit($this->ipp, $this->skip); } } // no need for paginator if there is only one page if ($this->total_pages <= 1) { return $this->destroy(); } if ($this->cur_page > 1) { /** @type View $v */ $v = $this->add('View', null, 'prev'); $v->setElement('a')->setAttr('href', $this->app->url($this->base_page, $u = array($this->skip_var => $pn = max(0, $this->skip - $this->ipp))))->setAttr('data-skip', $pn)->set('« Prev'); } else { $this->template->tryDel('prev'); } if ($this->cur_page < $this->total_pages) { /** @type View $v */ $v = $this->add('View', null, 'next'); $v->setElement('a')->setAttr('href', $this->app->url($this->base_page, $u = array($this->skip_var => $pn = $this->skip + $this->ipp)))->setAttr('data-skip', $pn)->set('Next »'); } else { $this->template->tryDel('next'); } // First page if ($this->cur_page > $this->range + 1) { /** @type View $v */ $v = $this->add('View', null, 'first'); $v->setElement('a')->setAttr('href', $this->app->url($this->base_page, $u = array($this->skip_var => $pn = max(0, 0))))->setAttr('data-skip', $pn)->set('1'); if ($this->cur_page > $this->range + 2) { /** @type View $v */ $v = $this->add('View', null, 'points_left'); $v->setElement('span')->set('...'); } } // Last page if ($this->cur_page < $this->total_pages - $this->range) { /** @type View $v */ $v = $this->add('View', null, 'last'); $v->setElement('a')->setAttr('href', $this->app->url($this->base_page, $u = array($this->skip_var => $pn = max(0, ($this->total_pages - 1) * $this->ipp))))->setAttr('data-skip', $pn)->set($this->total_pages); if ($this->cur_page < $this->total_pages - $this->range - 1) { /** @type View $v */ $v = $this->add('View', null, 'points_right'); $v->setElement('span')->set('...'); } } // generate source for Paginator Lister (pages, links, labels etc.) $data = array(); //setting cur as array seems not working in atk4.3. String is working $tplcur = $this->template->get('cur'); $tplcur = isset($tplcur[0]) ? $tplcur[0] : ''; $range = range(max(1, $this->cur_page - $this->range), min($this->total_pages, $this->cur_page + $this->range)); foreach ($range as $p) { $data[] = array('href' => $this->app->url($this->base_page, array($this->skip_var => $pn = ($p - 1) * $this->ipp)), 'pn' => $pn, 'cur' => $p == $this->cur_page ? $tplcur : '', 'label' => $p); } if ($this->ajax_reload) { $this->js('click', $this->owner->js()->reload(array($this->skip_var => $this->js()->_selectorThis()->attr('data-skip'))))->_selector('#' . $this->name . ' a'); } parent::setSource($data); return parent::recursiveRender(); }
<?php require_once "../model/session.php"; $model = new Model(); $controllerCalled = 1; $date = date("Y-m-d"); $guardSuccess = $model->count("tours", "mention = '#555' AND date_tour='" . $date . "'"); $guardBad = $model->count("tours", "mention='#dd5826' AND date_tour='" . $date . "'"); $guardWarning = $model->count("tours", "mention='#f0b518' AND date_tour='" . $date . "'"); $nbGuard = $model->count("tours", "date_tour='" . $date . "'"); $list = $model->dynamicSelectAll("tours", "date_tour='" . $date . "'", "*"); // echo "-------------------------------------------------------------"; // print_r($list); // echo "-------------------------------------------------------------"; // echo $date; if ($nbGuard != 0) { $pSuccess = round(doubleval($guardSuccess * 100) / $nbGuard, 2); $pWarning = round(doubleval($guardWarning * 100) / $nbGuard, 2); $pDanger = round(doubleval($guardBad * 100) / $nbGuard, 2); } else { $pSuccess = 0; $pWarning = 0; $pDanger = 0; } include "../vue/dashboard.php";
<?php require_once __DIR__ . '/Model.php'; require_once __DIR__ . '/Connect.php'; $database = ['host' => 'localhost', 'dbname' => 'ecole_multimedia', 'password' => 'root', 'username' => 'antoine']; $connect = new Connect($database); $model = new Model($connect->getDB()); $model->table = 'posts'; $posts = $model->select(['title', 'status', 'content'])->where('id', '>', 1)->where('status', '=', 'published')->get(); foreach ($posts as $post) { echo "<h1>{$post->title}</h1>"; } var_dump($model->count()); var_dump($model->where('id', '>', 1)->count());
public function order_exp_new() { import('ORG.Util.Page'); $model = new Model('exp_log'); $last_time = M('kongbao_type')->max('last_down_time'); if (empty($last_time)) { $last_time = '系统尚未进行过批量导出!'; } else { $last_time = date('Y-m-d H:i:s', $last_time); } $count = $model->count(); $page = new Page($count, 15); $show = $page->show(); $log_list = $model->order('exp_time desc')->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign('show', $show); $this->assign('count', $count); $this->assign('log_list', $log_list); $this->assign('last_time', $last_time); $type_list = $this->get_kongbao_type(); $this->assign('type_list', $type_list); $this->display(); }
/** +---------------------------------------------------------- * 根据表单生成查询条件 * 进行列表过滤 +---------------------------------------------------------- * @access protected +---------------------------------------------------------- * @param Model $model 数据对象 * @param HashMap $map 过滤条件 * @param string $sortBy 排序 * @param boolean $asc 是否正序 +---------------------------------------------------------- * @return void +---------------------------------------------------------- * @throws ThinkExecption +---------------------------------------------------------- */ protected function _list($model, $map, $sortBy = '', $asc = true) { //排序字段 默认为主键名 if (isset($_REQUEST['order'])) { $order = $_REQUEST['order']; } else { $order = !empty($sortBy) ? $sortBy : $model->getPk(); } //排序方式默认按照倒序排列 //接受 sost参数 0 表示倒序 非0都 表示正序 if (isset($_REQUEST['sort'])) { $sort = $_REQUEST['sort'] ? 'asc' : 'desc'; } else { $sort = $asc ? 'asc' : 'desc'; } //取得满足条件的记录数 $count = $model->count($map); if ($count > 0) { import("ORG.Util.Page"); //创建分页对象 if (!empty($_REQUEST['listRows'])) { $listRows = $_REQUEST['listRows']; } else { $listRows = ''; } $p = new Page($count, $listRows); //分页查询数据 $voList = $model->where($map)->order($order . ' ' . $sort)->limit($p->firstRow . ',' . $p->listRows)->findAll(); //分页跳转的时候保证查询条件 foreach ($map as $key => $val) { if (is_array($val)) { foreach ($val as $t) { $p->parameter .= $key . '[]=' . urlencode($t) . "&"; } } else { $p->parameter .= "{$key}=" . urlencode($val) . "&"; } } //分页显示 $page = $p->show(); //列表排序显示 $sortImg = $sort; //排序图标 $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列'; //排序提示 $sort = $sort == 'desc' ? 1 : 0; //排序方式 //模板赋值显示 $this->assign('list', $voList); $this->assign('sort', $sort); $this->assign('order', $order); $this->assign('sortImg', $sortImg); $this->assign('sortType', $sortAlt); $this->assign("page", $page); } return; }
public function totalPagina() { $conexao = new Model(); $conexao->setTabela('veiculos'); $confDados = $conexao->count($this->_where); $this->_pag_total_busca = $confDados ? $confDados->TOTAL : 0; }