one step towards faster searching

git-svn-id: file:///home/shish/svn/shimmie2/trunk@29 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2007-04-28 18:58:23 +00:00
parent d0b797247f
commit f12e0b8f60

View file

@ -81,6 +81,7 @@ class Database {
private function build_search_querylet($terms) { private function build_search_querylet($terms) {
$tag_search = new Querylet("0"); $tag_search = new Querylet("0");
$positive_tag_count = 0; $positive_tag_count = 0;
$negative_tag_count = 0;
$img_search = new Querylet(""); $img_search = new Querylet("");
foreach($terms as $term) { foreach($terms as $term) {
@ -114,12 +115,12 @@ class Database {
$term = str_replace("?", "_", $term); $term = str_replace("?", "_", $term);
$sign = $negative ? "-" : "+"; $sign = $negative ? "-" : "+";
if($sign == "+") $positive_tag_count++; if($sign == "+") $positive_tag_count++;
else $negative_tag_count++;
$tag_search->append(new Querylet(" $sign (tag LIKE ?)", array($term))); $tag_search->append(new Querylet(" $sign (tag LIKE ?)", array($term)));
} }
} }
$database_fails = false; // MySQL 4.0 fails at subqueries if($positive_tag_count + $negative_tag_count == 0) {
if(count($tag_search->variables) == 0 || $database_fails) {
$query = new Querylet("SELECT * FROM images "); $query = new Querylet("SELECT * FROM images ");
} }
else { else {