From 6ce32ce9aa391b8c18bf030093838c204021c4aa Mon Sep 17 00:00:00 2001 From: Stephan Poehlsen Date: Wed, 23 Nov 2005 03:50:46 +0000 Subject: bug: crawler_id in provider_record added git-svn-id: file:///home/lennart/svn/public/sse/trunk@38 5fbabb74-0606-0410-a5e4-b5cc6a42724e --- www/index.php | 58 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 16 deletions(-) (limited to 'www/index.php') diff --git a/www/index.php b/www/index.php index 6dc0bbe..81ee0b4 100644 --- a/www/index.php +++ b/www/index.php @@ -34,12 +34,40 @@ if (isset($_REQUEST['start'])) { } - ////////////////////////////////////////////////////////////////////////// -// create form fields +// page header $title = 'Source Search Engine'.($q ? ' - '.htmlentities($q) : ''); +echo << + + + +$title + + +ECHOFORM; + +db_connect(); + +$identifier = 0; +$res = mysql_query("SHOW TABLE STATUS"); +if ($res) { + while ($r = mysql_fetch_array($res)) { + if ($r['Name'] == 'word') $identifier = $r['Rows']; + } +} + +if ($identifier) { + echo('

'.$identifier." in DB

\n"); +} + + + +////////////////////////////////////////////////////////////////////////// +// create form fields + $ME = $_SERVER['PHP_SELF']; $escaped_q = htmlentities($q); $subword_checked = ($subword ? ' checked="checked" ' : ''); @@ -50,13 +78,6 @@ $hidden_form = ($num != $num_default ? ' - - - -$title - -
$hidden_form @@ -99,16 +120,18 @@ while ($q) { } - $sql = "SELECT COUNT(*)/COUNT(DISTINCT pr.id) AS keywords_cnt, ". + $sql = "SELECT SQL_CALC_FOUND_ROWS COUNT(*)/COUNT(DISTINCT pr.id) AS keywords_cnt, ". " SUM(w.cnt)/COUNT(DISTINCT pr.id) AS cnt, " . " f.path, f.language_id, pr.id AS prid, pr.name AS package_name ". " FROM word AS w, file AS f, package AS p, provider_record AS pr ". " WHERE p.id=pr.package_id AND ".$where. " AND w.file_id=f.id AND f.package_id=p.id ". - " AND f.crawler_id=w.crawler_id AND f.crawler_id=p.crawler_id ". + " AND f.crawler_id=w.crawler_id AND f.crawler_id=p.crawler_id AND pr.crawler_id=f.crawler_id ". " GROUP BY f.crawler_id, f.id ". - " ORDER BY keywords_cnt DESC, w.cnt DESC "; + " ORDER BY keywords_cnt DESC, w.cnt DESC ". + " LIMIT ".$start.", ".$num; + //echo(htmlentities($sql)); exit; break; } @@ -121,8 +144,6 @@ while ($q) { $total = 0; while (isset($sql) and $sql) { - db_connect(); - // use LIMIT ==> two queries: 1. total count, 2. results // or mysql query cache ==> one query (dump data) @@ -131,7 +152,12 @@ while (isset($sql) and $sql) { echo('

'.mysql_errno().': '.mysql_error()."
\n".$sql."

\n"); break; } - $total = mysql_num_rows($res); + + $res2 = mysql_query("SELECT FOUND_ROWS() AS cnt"); + if ($r2 = mysql_fetch_array($res2)) { + $total = $r2['cnt']; + } + //$total = mysql_num_rows($res); break; } @@ -140,7 +166,7 @@ $max_page = max(1, ceil($total/$num)); $max_start = ($max_page-1)*$num; // behind last result page -if ($start > $max_start) $start = $max_start; +//if ($start > $max_start) $start = $max_start; // start not aligned //$start = floor($start/$num)*$num; -- cgit