PMA\libraries\DbSearch::getSearchResults PHP Метод

getSearchResults() публичный Метод

Displays database search results
public getSearchResults ( ) : string
Результат string HTML for search results
    public function getSearchResults()
    {
        $html_output = '';
        // Displays search string
        $html_output .= '<br />' . '<table class="data">' . '<caption class="tblHeaders">' . sprintf(__('Search results for "<i>%s</i>" %s:'), htmlspecialchars($this->_criteriaSearchString), $this->_searchTypeDescription) . '</caption>';
        $num_search_result_total = 0;
        // For each table selected as search criteria
        foreach ($this->_criteriaTables as $each_table) {
            // Gets the SQL statements
            $newsearchsqls = $this->_getSearchSqls($each_table);
            // Executes the "COUNT" statement
            $res_cnt = $GLOBALS['dbi']->fetchValue($newsearchsqls['select_count']);
            $num_search_result_total += $res_cnt;
            // Gets the result row's HTML for a table
            $html_output .= $this->_getResultsRow($each_table, $newsearchsqls, $res_cnt);
        }
        // end for
        $html_output .= '</table>';
        // Displays total number of matches
        if (count($this->_criteriaTables) > 1) {
            $html_output .= '<p>';
            $html_output .= sprintf(_ngettext('<b>Total:</b> <i>%s</i> match', '<b>Total:</b> <i>%s</i> matches', $num_search_result_total), $num_search_result_total);
            $html_output .= '</p>';
        }
        return $html_output;
    }

Usage Example

Пример #1
0
$scripts->addFile('sql.js');
$scripts->addFile('makegrid.js');
$scripts->addFile('jquery/jquery-ui-timepicker-addon.js');
require 'libraries/db_common.inc.php';
// If config variable $GLOBALS['cfg']['UseDbSearch'] is on false : exit.
if (!$GLOBALS['cfg']['UseDbSearch']) {
    PMA\libraries\Util::mysqlDie(__('Access denied!'), '', false, $err_url);
}
// end if
$url_query .= '&amp;goto=db_search.php';
$url_params['goto'] = 'db_search.php';
// Create a database search instance
$db_search = new DbSearch($GLOBALS['db']);
// Display top links if we are not in an Ajax request
if (!$response->isAjax()) {
    list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
}
// Main search form has been submitted, get results
if (isset($_REQUEST['submit_search'])) {
    $response->addHTML($db_search->getSearchResults());
}
// If we are in an Ajax request, we need to exit after displaying all the HTML
if ($response->isAjax() && empty($_REQUEST['ajax_page_request'])) {
    exit;
}
// Display the search form
$response->addHTML($db_search->getSelectionForm());
$response->addHTML('<div id="searchresults"></div>');
$response->addHTML('<div id="togglesearchresultsdiv"><a id="togglesearchresultlink"></a></div>');
$response->addHTML('<br class="clearfloat" />');
$response->addHTML($db_search->getResultDivs());