summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Poehlsen <stephan@poehlsen.net>2005-11-23 03:50:46 +0000
committerStephan Poehlsen <stephan@poehlsen.net>2005-11-23 03:50:46 +0000
commit6ce32ce9aa391b8c18bf030093838c204021c4aa (patch)
tree2c2f1cd1752792d352aaa6ad675a7604f25354cf
parente7ffaa83e4a12c0f44f247181ea2eaf981e09bc6 (diff)
bug: crawler_id in provider_record added
git-svn-id: file:///home/lennart/svn/public/sse/trunk@38 5fbabb74-0606-0410-a5e4-b5cc6a42724e
-rw-r--r--www/index.php58
1 files changed, 42 insertions, 16 deletions
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 <<<ECHOFORM
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"/>
+<title>$title</title>
+</head>
+<body>
+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('<p>'.$identifier." in DB</p>\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 ? '<input type="hidden" name="num" value="'
$ME = preg_replace('/index\.php$/', '', $ME);
echo <<<ECHOFORM
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"/>
-<title>$title</title>
-</head>
-<body>
<div class="formbox">
<form action="$ME" method="get">$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('<p class="error">'.mysql_errno().': '.mysql_error()."<br />\n".$sql."</p>\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;