本文整理汇总了PHP中pagination::genPages方法的典型用法代码示例。如果您正苦于以下问题:PHP pagination::genPages方法的具体用法?PHP pagination::genPages怎么用?PHP pagination::genPages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pagination
的用法示例。
在下文中一共展示了pagination::genPages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pagination
public static function pagination($allCount, $offset = 1)
{
$offset = intval(system::HTTPGet("offset"));
if ($offset == 0) {
$offset = 1;
}
$smarty = array();
$smarty["itemsOnPage"] = intval(system::param("itemsOnPage"));
$smarty["offset"] = $offset;
$smarty["allCount"] = $allCount;
$pageCompose = new pagination($allCount);
$pageCompose->setPerPage($smarty["itemsOnPage"]);
$pageCompose->readInputData($offset);
$mysqlLimits = $pageCompose->calculateOffset();
$smarty["pages"] = $pageCompose->genPages();
$smarty["pagesTotal"] = count($smarty["pages"]);
system::$core->smarty->assign("pagination", $smarty);
return $mysqlLimits;
}
示例2: buildList
public static function buildList($target, $clause = '')
{
$columns = self::$db->query("SHOW COLUMNS FROM `{$target}`")->fetchAll();
if (isset($_GET["action"])) {
switch ($_GET["action"]) {
case "delete":
$id = array_keys($_GET);
$keyName = $id[count($_GET) - 1];
$id = intval($_GET[$keyName]);
$photo = self::$db->query("SELECT * FROM `{$target}` WHERE `?`=?", $keyName, $id)->fetch();
if ($photo) {
self::$db->query("DELETE FROM `{$target}` WHERE `?`=?", $keyName, $id);
unlink(CONTENT_PATH . '/photo/original/' . $photo['picture']);
unlink(CONTENT_PATH . '/photo/resized/' . $photo['picture']);
unlink(CONTENT_PATH . '/photo/200x200/' . $photo['picture']);
unlink(CONTENT_PATH . '/photo/200x140/' . $photo['picture']);
}
if ($target == "content") {
self::$db->query("DELETE FROM `photo` WHERE `contentID`=?", $id);
self::$smarty->clearCache(null, "MAINPAGE");
self::$smarty->clearCache(null, "RSS");
self::$smarty->clearCache(null, "SEARCH_RES");
}
break;
}
}
if (isset($_POST["groupDelete"]) && !empty($_POST["rows"])) {
self::$db->query("DELETE FROM `{$target}` WHERE `" . $columns[0]["Field"] . "` IN (" . implode(",", $_POST["rows"]) . ")");
}
$mysqlLimits = array();
$offset = 0;
$allCount = self::$db->query("SELECT COUNT(*) as cnt FROM `{$target}` WHERE 1 " . $clause)->fetch();
$pageCompose = new pagination($allCount["cnt"]);
$sort = $columns[0]["Field"];
$direction = "DESC";
if (!empty(self::$get["offset"])) {
$offset = intval(self::$get["offset"]);
}
if (isset($_GET["direction"]) && $_GET["direction"]) {
if ($_GET["direction"] == "DESC") {
$direction = "ASC";
} else {
if ($_GET["direction"] == "ASC") {
$direction = "DESC";
}
}
}
if (isset($_GET["sort"]) && $_GET["sort"]) {
$sort = $_GET["sort"];
}
$pageCompose->readInputData($offset, 20);
$mysqlLimits = $pageCompose->calculateOffset();
$pages = $pageCompose->genPages();
self::$smarty->assign("pages", $pages);
self::$smarty->assign("direction", $direction);
self::$smarty->assign("sort", $sort);
self::$smarty->assign("allCount", $allCount["cnt"]);
$sqlData = self::$db->query("SELECT * FROM `{$target}` WHERE 1 {$clause} ORDER BY `{$sort}` {$direction} LIMIT {$mysqlLimits["start"]},{$mysqlLimits["end"]}")->fetchAll();
self::$smarty->assign("list", $sqlData);
return $sqlData;
}
示例3: buildList
public static function buildList($target, $type = "", array $clause = array())
{
$clauseSTR = "";
if ($clause) {
$clauseSTR = implode(" AND ", $clause);
}
if ($clauseSTR) {
$clauseSTR = "WHERE {$clauseSTR}";
}
$columns = self::$db->query("SHOW COLUMNS FROM `{$target}`")->fetchAll();
if (isset($_GET["action"])) {
switch ($_GET["action"]) {
case "delete":
$id = array_keys($_GET);
$keyName = $id[count($_GET) - 1];
$id = intval($_GET[$keyName]);
self::$db->query("DELETE FROM `{$target}` WHERE `?`=?", $keyName, $id);
if ($target == "content") {
self::$db->query("DELETE FROM `content_category` WHERE `id`=?", $id);
}
self::$smarty->clearAllCache();
break;
}
}
if (isset($_POST["groupDelete"]) && !empty($_POST["rows"])) {
self::$db->query("DELETE FROM `{$target}` WHERE `" . $columns[0]["Field"] . "` IN (" . implode(",", $_POST["rows"]) . ")");
}
$mysqlLimits = array();
$offset = 1;
$allCount = self::$db->query("SELECT COUNT(*) as cnt FROM `{$target}` {$clauseSTR}")->fetch();
$pageCompose = new pagination($allCount["cnt"]);
$sort = $columns[0]["Field"];
$direction = "DESC";
if (!empty(self::$get["offset"])) {
$offset = intval(self::$get["offset"]);
}
if (isset($_GET["direction"]) && $_GET["direction"]) {
if ($_GET["direction"] == "DESC") {
$direction = "ASC";
} else {
if ($_GET["direction"] == "ASC") {
$direction = "DESC";
}
}
}
if (isset($_GET["sort"]) && $_GET["sort"]) {
$sort = $_GET["sort"];
}
$pageCompose->readInputData($offset, 20);
$mysqlLimits = $pageCompose->calculateOffset();
$pages = $pageCompose->genPages();
self::$smarty->assign("pages", $pages);
self::$smarty->assign("direction", $direction);
self::$smarty->assign("sort", $sort);
self::$smarty->assign("allCount", $allCount["cnt"]);
$sqlData = self::$db->query("SELECT * FROM `{$target}` {$clauseSTR} ORDER BY `{$sort}` {$direction} LIMIT \n\t\t\t{$mysqlLimits["start"]},{$mysqlLimits["end"]}");
if ($target != "categories") {
$sqlData->runAfterFetchAll[] = array("news", "makeSlug");
}
$res = $sqlData->fetchAll();
self::$smarty->assign("list", $res);
return $res;
}