本文整理汇总了PHP中Pager::queryRowsBySQL方法的典型用法代码示例。如果您正苦于以下问题:PHP Pager::queryRowsBySQL方法的具体用法?PHP Pager::queryRowsBySQL怎么用?PHP Pager::queryRowsBySQL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pager
的用法示例。
在下文中一共展示了Pager::queryRowsBySQL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trim
<?php
require_once './inc/init.php';
require_once './inc/pager.php';
$k = trim($_GET['k']);
$curPage = intval($_GET["page"]);
$pagerlink = $webcore->genUrl("search.php?page={page}" . (empty($k) ? "" : "&k={$k}"));
$tempsql .= "\r\n (\r\n\tSELECT 1 as rtype,id,name as title,posttime,content FROM {$db->pre}products WHERE langid={$_SYS['langid']} and (name like '%{$k}%' or content like '%{$k}%')\r\n\tUNION ALL\r\n\tSELECT 2 as rtype,id,title,posttime,content FROM {$db->pre}articles WHERE langid={$_SYS['langid']} and (title like '%{$k}%' or content like '%{$k}%')\r\n\tUNION ALL\r\n\tSELECT 3 as rtype,id,title,null as posttime,content FROM {$db->pre}channels WHERE langid={$_SYS['langid']} and (content like '%{$k}%' or content like '%{$k}%')\r\n) TEMPTB\r\n";
$recordnum = $db->row_query_one("SELECT count(1) as total FROM {$tempsql}");
$recordnum = intval($recordnum['total']);
$recordnumstr = _LANG($_SLANG['search.total'], array($recordnum));
$pager = new Pager();
$pager->init(10, $curPage, $pagerlink);
$res = $pager->queryRowsBySQL($db, "SELECT * FROM {$tempsql} ORDER BY posttime DESC", $recordnum);
foreach ($res as $key => $rs) {
switch ($rs['rtype']) {
case 1:
$rs['link'] = $webcore->genUrl("product.php?id={$rs['id']}");
$rs['posttime'] = getDateStr($rs['posttime']);
break;
case 2:
$rs['link'] = $webcore->genUrl("view.php?id={$rs['id']}");
$rs['posttime'] = getDateStr($rs['posttime']);
break;
case 3:
$rs['link'] = $webcore->genUrl("page.php?cid={$rs['id']}");
$rs['posttime'] = "";
break;
}
$rs['type'] = $_SLANG['search.types'][intval($rs['rtype'])];
$rs['title'] = htmlFilter($rs['title']);