/**
* Set the content that needs to be shown in message
*
* @param string $sorted_column_message the message for sorted column
* @param array $analyzed_sql_results the analyzed query
* @param integer $total the total number of rows returned by
* the SQL query without any
* programmatically appended LIMIT clause
* @param integer $pos_next the offset for next page
* @param string $pre_count the string renders before row count
* @param string $after_count the string renders after row count
*
* @return Message $message an object of Message
*
* @access private
*
* @see getTable()
*/
private function _setMessageInformation($sorted_column_message, $analyzed_sql_results, $total, $pos_next, $pre_count, $after_count)
{
$unlim_num_rows = $this->__get('unlim_num_rows');
// To use in isset()
if (!empty($analyzed_sql_results['statement']->limit)) {
$first_shown_rec = $analyzed_sql_results['statement']->limit->offset;
$row_count = $analyzed_sql_results['statement']->limit->rowCount;
if ($row_count < $total) {
$last_shown_rec = $first_shown_rec + $row_count - 1;
} else {
$last_shown_rec = $first_shown_rec + $total - 1;
}
} elseif ($_SESSION['tmpval']['max_rows'] == self::ALL_ROWS || $pos_next > $total) {
$first_shown_rec = $_SESSION['tmpval']['pos'];
$last_shown_rec = $total - 1;
} else {
$first_shown_rec = $_SESSION['tmpval']['pos'];
$last_shown_rec = $pos_next - 1;
}
$table = new Table($this->__get('table'), $this->__get('db'));
if ($table->isView() && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
$message = Message::notice(__('This view has at least this number of rows. ' . 'Please refer to %sdocumentation%s.'));
$message->addParam('[doc@cfg_MaxExactCount]');
$message->addParam('[/doc]');
$message_view_warning = Util::showHint($message);
} else {
$message_view_warning = false;
}
$message = Message::success(__('Showing rows %1s - %2s'));
$message->addParam($first_shown_rec);
if ($message_view_warning !== false) {
$message->addParam('... ' . $message_view_warning, false);
} else {
$message->addParam($last_shown_rec);
}
$message->addMessage('(');
if ($message_view_warning === false) {
if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
$message_total = Message::notice($pre_count . __('%1$d total, %2$d in query'));
$message_total->addParam($total);
$message_total->addParam($unlim_num_rows);
} else {
$message_total = Message::notice($pre_count . __('%d total'));
$message_total->addParam($total);
}
if (!empty($after_count)) {
$message_total->addMessage($after_count);
}
$message->addMessage($message_total, '');
$message->addMessage(', ', '');
}
$message_qt = Message::notice(__('Query took %01.4f seconds.') . ')');
$message_qt->addParam($this->__get('querytime'));
$message->addMessage($message_qt, '');
if (!is_null($sorted_column_message)) {
$message->addMessage($sorted_column_message, '');
}
return $message;
}