本文整理汇总了PHP中Pager::getTotalRows方法的典型用法代码示例。如果您正苦于以下问题:PHP Pager::getTotalRows方法的具体用法?PHP Pager::getTotalRows怎么用?PHP Pager::getTotalRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pager
的用法示例。
在下文中一共展示了Pager::getTotalRows方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEmailListing
/**
* Method used to get the list of emails to be displayed in the
* grid layout.
*
* @param array $options The search parameters
* @param integer $current_row The current page number
* @param integer $max The maximum number of rows per page
* @return array The list of issues to be displayed
*/
public static function getEmailListing($options, $current_row = 0, $max = 5)
{
$prj_id = Auth::getCurrentProject();
if ($max == 'ALL') {
$max = 9999999;
}
$start = $current_row * $max;
$stmt = 'SELECT
sup_id,
sup_ema_id,
sup_iss_id,
sup_customer_id,
sup_from,
sup_date,
sup_to,
sup_subject,
sup_has_attachment
FROM
(
{{%support_email}},
{{%email_account}}';
if (!empty($options['keywords'])) {
$stmt .= ', {{%support_email_body}} ';
}
$stmt .= '
)
LEFT JOIN
{{%issue}}
ON
sup_iss_id = iss_id';
$stmt .= self::buildWhereClause($options);
$stmt .= '
ORDER BY
' . Misc::escapeString($options['sort_by']) . ' ' . Misc::escapeString($options['sort_order']);
$total_rows = Pager::getTotalRows($stmt);
$stmt .= '
LIMIT
' . Misc::escapeInteger($max) . ' OFFSET ' . Misc::escapeInteger($start);
try {
$res = DB_Helper::getInstance()->getAll($stmt);
} catch (DbException $e) {
return array('list' => '', 'info' => '');
}
if (count($res) < 1 && $current_row > 0) {
// if there are no results, and the page is not the first page reset page to one and reload results
Auth::redirect("emails.php?pagerRow=0&rows={$max}");
}
if (CRM::hasCustomerIntegration($prj_id)) {
$crm = CRM::getInstance($prj_id);
$customer_ids = array();
foreach ($res as $row) {
if (!empty($row['sup_customer_id']) && !in_array($row['sup_customer_id'], $customer_ids)) {
$customer_ids[] = $row['sup_customer_id'];
}
}
if (count($customer_ids) > 0) {
$company_titles = $crm->getCustomerTitles($customer_ids);
}
}
foreach ($res as &$row) {
$row['sup_date'] = Date_Helper::getFormattedDate($row['sup_date']);
$row['sup_subject'] = Mime_Helper::fixEncoding($row['sup_subject']);
$row['sup_from'] = implode(', ', Mail_Helper::getName($row['sup_from'], true));
if (empty($row['sup_to']) && !empty($row['sup_iss_id'])) {
$row['sup_to'] = 'Notification List';
} else {
$to = Mail_Helper::getName($row['sup_to']);
// Ignore unformattable headers
if (!Misc::isError($to)) {
$row['sup_to'] = Mime_Helper::fixEncoding($to);
}
}
if (CRM::hasCustomerIntegration($prj_id)) {
// FIXME: $company_titles maybe used uninitialied
$row['customer_title'] = $company_titles[$row['sup_customer_id']];
}
}
$total_pages = ceil($total_rows / $max);
$last_page = $total_pages - 1;
return array('list' => $res, 'info' => array('current_page' => $current_row, 'start_offset' => $start, 'end_offset' => $start + count($res), 'total_rows' => $total_rows, 'total_pages' => $total_pages, 'previous_page' => $current_row == 0 ? '-1' : $current_row - 1, 'next_page' => $current_row == $last_page ? '-1' : $current_row + 1, 'last_page' => $last_page));
}
示例2: getEmailListing
/**
* Method used to get the list of emails to be displayed in the
* grid layout.
*
* @access public
* @param array $options The search parameters
* @param integer $current_row The current page number
* @param integer $max The maximum number of rows per page
* @return array The list of issues to be displayed
*/
function getEmailListing($options, $current_row = 0, $max = 5)
{
$prj_id = Auth::getCurrentProject();
$usr_id = Auth::getUserID();
if ($max == "ALL") {
$max = 9999999;
}
$start = $current_row * $max;
$stmt = "SELECT\n sup_id,\n sup_ema_id,\n sup_iss_id,\n sup_customer_id,\n sup_from,\n sup_date,\n sup_to,\n sup_subject,\n sup_has_attachment\n FROM\n (\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account";
if (!empty($options['keywords'])) {
$stmt .= "," . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email_body";
}
$stmt .= "\n )\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue\n ON\n sup_iss_id = iss_id";
$stmt .= Support::buildWhereClause($options);
$stmt .= "\n ORDER BY\n " . Misc::escapeString($options["sort_by"]) . " " . Misc::escapeString($options["sort_order"]);
$total_rows = Pager::getTotalRows($stmt);
$stmt .= "\n LIMIT\n " . Misc::escapeInteger($start) . ", " . Misc::escapeInteger($max);
$res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
return array("list" => "", "info" => "");
} else {
if (count($res) < 1 && $current_row > 0) {
// if there are no results, and the page is not the first page reset page to one and reload results
Auth::redirect(APP_RELATIVE_URL . "emails.php?pagerRow=0&rows={$max}");
}
if (Customer::hasCustomerIntegration($prj_id)) {
$customer_ids = array();
for ($i = 0; $i < count($res); $i++) {
if (!empty($res[$i]['sup_customer_id']) && !in_array($res[$i]['sup_customer_id'], $customer_ids)) {
$customer_ids[] = $res[$i]['sup_customer_id'];
}
}
if (count($customer_ids) > 0) {
$company_titles = Customer::getTitles($prj_id, $customer_ids);
}
}
for ($i = 0; $i < count($res); $i++) {
$res[$i]["sup_date"] = Date_API::getFormattedDate($res[$i]["sup_date"]);
$res[$i]["sup_subject"] = Mime_Helper::fixEncoding($res[$i]["sup_subject"]);
$res[$i]["sup_from"] = join(', ', Mail_API::getName($res[$i]["sup_from"], true));
if (empty($res[$i]["sup_to"]) && !empty($res[$i]["sup_iss_id"])) {
$res[$i]["sup_to"] = "Notification List";
} else {
$res[$i]["sup_to"] = Mime_Helper::fixEncoding(Mail_API::getName($res[$i]["sup_to"]));
}
if (Customer::hasCustomerIntegration($prj_id)) {
@($res[$i]['customer_title'] = $company_titles[$res[$i]['sup_customer_id']]);
}
}
$total_pages = ceil($total_rows / $max);
$last_page = $total_pages - 1;
return array("list" => $res, "info" => array("current_page" => $current_row, "start_offset" => $start, "end_offset" => $start + count($res), "total_rows" => $total_rows, "total_pages" => $total_pages, "previous_page" => $current_row == 0 ? "-1" : $current_row - 1, "next_page" => $current_row == $last_page ? "-1" : $current_row + 1, "last_page" => $last_page));
}
}
示例3: getListing
//.........这里部分代码省略.........
LEFT JOIN
{{%issue_user_replier}}
ON
iur_iss_id=iss_id';
}
if (!empty($options['show_notification_list_issues'])) {
$stmt .= '
LEFT JOIN
{{%subscription}}
ON
sub_iss_id=iss_id';
}
if (!empty($options['product'])) {
$stmt .= '
LEFT JOIN
{{%issue_product_version}}
ON
ipv_iss_id=iss_id';
}
$stmt .= "\n LEFT JOIN\n {{%group}}\n ON\n iss_grp_id=grp_id\n LEFT JOIN\n {{%project_category}}\n ON\n iss_prc_id=prc_id\n LEFT JOIN\n {{%project_release}}\n ON\n iss_pre_id = pre_id\n LEFT JOIN\n {{%status}}\n ON\n iss_sta_id=sta_id\n LEFT JOIN\n {{%project_priority}}\n ON\n iss_pri_id=pri_id\n LEFT JOIN\n {{%project_severity}}\n ON\n iss_sev_id=sev_id\n LEFT JOIN\n {{%issue_quarantine}}\n ON\n iss_id=iqu_iss_id AND\n (iqu_expiration > '" . Date_Helper::getCurrentDateGMT() . "' OR iqu_expiration IS NULL)\n WHERE\n iss_prj_id= " . Misc::escapeInteger($prj_id);
$stmt .= self::buildWhereClause($options);
if (strstr($options['sort_by'], 'custom_field') !== false) {
$fld_details = Custom_Field::getDetails($fld_id);
$sort_by = 'cf_sort.' . Custom_Field::getDBValueFieldNameByType($fld_details['fld_type']);
} else {
$sort_by = Misc::escapeString($options['sort_by']);
}
$stmt .= '
GROUP BY
iss_id
ORDER BY
' . $sort_by . ' ' . Misc::escapeString($options['sort_order']) . ',
iss_id DESC';
$total_rows = Pager::getTotalRows($stmt);
$stmt .= '
LIMIT
' . Misc::escapeInteger($max) . ' OFFSET ' . Misc::escapeInteger($start);
try {
$res = DB_Helper::getInstance()->getAll($stmt);
} catch (DbException $e) {
return array('list' => null, 'info' => null, 'csv' => null);
}
if (count($res) > 0) {
Issue::getAssignedUsersByIssues($res);
Time_Tracking::fillTimeSpentByIssues($res);
// need to get the customer titles for all of these issues...
if (CRM::hasCustomerIntegration($prj_id)) {
$crm = CRM::getInstance($prj_id);
$crm->processListIssuesResult($res);
}
Issue::formatLastActionDates($res);
Issue::getLastStatusChangeDates($prj_id, $res);
} elseif ($current_row > 0) {
// if there are no results, and the page is not the first page reset page to one and reload results
Auth::redirect("list.php?pagerRow=0&rows={$max}");
}
$groups = Group::getAssocList($prj_id);
$categories = Category::getAssocList($prj_id);
$column_headings = array();
$columns_to_display = Display_Column::getColumnsToDisplay($prj_id, 'list_issues');
foreach ($columns_to_display as $col_key => $column) {
if ($col_key == 'custom_fields' && count($custom_fields) > 0) {
foreach ($custom_fields as $fld_id => $fld_title) {
$column_headings['cstm_' . $fld_id] = $fld_title;
}
} else {
示例4: getListing
/**
* Method used to get the list of issues to be displayed in the grid layout.
*
* @access public
* @param integer $prj_id The current project ID
* @param array $options The search parameters
* @param integer $current_row The current page number
* @param integer $max The maximum number of rows per page
* @return array The list of issues to be displayed
*/
function getListing($prj_id, $options, $current_row = 0, $max = 5, $get_reporter = FALSE)
{
if (strtoupper($max) == "ALL") {
$max = 9999999;
}
$start = $current_row * $max;
// get the current user's role
$usr_id = Auth::getUserID();
$role_id = User::getRoleByUser($usr_id, $prj_id);
// get any custom fields that should be displayed
$custom_fields = Custom_Field::getFieldsToBeListed($prj_id);
$stmt = "SELECT\n iss_id,\n iss_grp_id,\n iss_prj_id,\n iss_sta_id,\n iss_customer_id,\n iss_created_date,\n iss_updated_date,\n iss_last_response_date,\n iss_closed_date,\n iss_last_customer_action_date,\n iss_usr_id,\n iss_summary,\n pri_title,\n prc_title,\n sta_title,\n sta_color status_color,\n sta_id,\n iqu_status,\n grp_name `group`,\n pre_title,\n iss_last_public_action_date,\n iss_last_public_action_type,\n iss_last_internal_action_date,\n iss_last_internal_action_type,\n " . Issue::getLastActionFields() . ",\n IF(iss_last_internal_action_date > iss_last_public_action_date, 'internal', 'public') AS action_type,\n iss_private,\n CONCAT(en_firstname,' ', en_lastname) as usr_full_name,\n iss_percent_complete,\n iss_dev_time,\n iss_expected_resolution_date\n FROM\n (\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n " . ETEL_USER_TABLE_NOSUB . "";
// join custom fields if we are searching by custom fields
if (is_array($options['custom_field']) && count($options['custom_field']) > 0) {
foreach ($options['custom_field'] as $fld_id => $search_value) {
if (empty($search_value)) {
continue;
}
$field = Custom_Field::getDetails($fld_id);
if ($field['fld_type'] == 'date' && (empty($search_value['Year']) || empty($search_value['Month']) || empty($search_value['Day']))) {
continue;
}
if ($field['fld_type'] == 'multiple') {
$search_value = Misc::escapeInteger($search_value);
foreach ($search_value as $cfo_id) {
$stmt .= ",\n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf" . $fld_id . '_' . $cfo_id . "\n";
}
} else {
$stmt .= ",\n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf" . $fld_id . "\n";
}
}
}
$stmt .= ")";
// check for the custom fields we want to sort by
if (strstr($options['sort_by'], 'custom_field') !== false) {
$fld_id = str_replace("custom_field_", '', $options['sort_by']);
$stmt .= "\n LEFT JOIN \n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf_sort\n ON\n (cf_sort.icf_iss_id = iss_id AND cf_sort.icf_fld_id = {$fld_id}) \n";
}
// START ETEL MODIFIED
if (!empty($options["show_authorized_issues"]) || $role_id <= User::getRoleID("Standard User") && Project::getSegregateReporters($prj_id)) {
$stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user_replier\n ON\n iur_iss_id=iss_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user\n ON\n isu_iss_id=iss_id";
} else {
if (!empty($options["users"])) {
$stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user\n ON\n isu_iss_id=iss_id";
}
}
// END ETEL MODIFIED
if (!empty($options["show_notification_list_issues"])) {
$stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription\n ON\n sub_iss_id=iss_id";
}
$stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . ".`" . APP_TABLE_PREFIX . "group`\n ON\n iss_grp_id=grp_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_category\n ON\n iss_prc_id=prc_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_release\n ON\n iss_pre_id = pre_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n ON\n iss_sta_id=sta_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority\n ON\n iss_pri_id=pri_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_quarantine\n ON\n iss_id=iqu_iss_id AND\n (iqu_expiration > '" . Date_API::getCurrentDateGMT() . "' OR iqu_expiration IS NULL)\n WHERE\n iss_prj_id= " . Misc::escapeInteger($prj_id);
$stmt .= Issue::buildWhereClause($options);
//echo $stmt;
if (strstr($options["sort_by"], 'custom_field') !== false) {
$sort_by = 'cf_sort.icf_value';
} else {
$sort_by = Misc::escapeString($options["sort_by"]);
}
$stmt .= "\n GROUP BY\n iss_id\n ORDER BY\n " . $sort_by . " " . Misc::escapeString($options["sort_order"]) . ",\n iss_id DESC";
$total_rows = Pager::getTotalRows($stmt);
if ($max > 100) {
$max = 100;
}
$stmt .= "\n LIMIT\n " . Misc::escapeInteger($start) . ", " . Misc::escapeInteger($max);
$res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
// echo $stmt;
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
return array("list" => "", "info" => "");
} else {
if (count($res) > 0) {
if ($get_reporter) {
Issue::getReportersByIssues($res);
}
Issue::getAssignedUsersByIssues($res);
Time_Tracking::getTimeSpentByIssues($res);
// need to get the customer titles for all of these issues...
if (Customer::hasCustomerIntegration($prj_id)) {
Customer::getCustomerTitlesByIssues($prj_id, $res);
}
Issue::formatLastActionDates($res);
Issue::getLastStatusChangeDates($prj_id, $res);
} elseif ($current_row > 0) {
// if there are no results, and the page is not the first page reset page to one and reload results
Auth::redirect(APP_RELATIVE_URL . "list.php?pagerRow=0&rows={$max}");
}
$groups = Group::getAssocList($prj_id);
$categories = Category::getAssocList($prj_id);
$column_headings = Issue::getColumnHeadings($prj_id);
if (count($custom_fields) > 0) {
//.........这里部分代码省略.........