fix single-tag + image metadata search
git-svn-id: file:///home/shish/svn/shimmie2/trunk@213 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
a92b2fdcab
commit
14a8c16d04
2 changed files with 16 additions and 7 deletions
|
@ -150,11 +150,20 @@ class Database {
|
||||||
|
|
||||||
if($positive_tag_count + $negative_tag_count == 0) {
|
if($positive_tag_count + $negative_tag_count == 0) {
|
||||||
$query = new Querylet($this->get_images);
|
$query = new Querylet($this->get_images);
|
||||||
|
|
||||||
|
if(strlen($img_search->sql) > 0) {
|
||||||
|
$query->append_sql("WHERE 1=1 ");
|
||||||
|
$query->append($img_search);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if($positive_tag_count == 1 && $negative_tag_count == 0) {
|
else if($positive_tag_count == 1 && $negative_tag_count == 0) {
|
||||||
$query = new Querylet(
|
$query = new Querylet(
|
||||||
"{$this->get_images} WHERE images.id IN (SELECT image_id FROM tags WHERE tag = ?) ",
|
"{$this->get_images} WHERE images.id IN (SELECT image_id FROM tags WHERE tag = ?) ",
|
||||||
$tag_search->variables);
|
$tag_search->variables);
|
||||||
|
|
||||||
|
if(strlen($img_search->sql) > 0) {
|
||||||
|
$query->append($img_search);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$s_tag_array = array_map("sql_escape", $tag_search->variables);
|
$s_tag_array = array_map("sql_escape", $tag_search->variables);
|
||||||
|
@ -175,11 +184,11 @@ class Database {
|
||||||
$query = new Querylet("
|
$query = new Querylet("
|
||||||
SELECT *, UNIX_TIMESTAMP(posted) AS posted_timestamp
|
SELECT *, UNIX_TIMESTAMP(posted) AS posted_timestamp
|
||||||
FROM ({$subquery->sql}) AS images ", $subquery->variables);
|
FROM ({$subquery->sql}) AS images ", $subquery->variables);
|
||||||
}
|
|
||||||
|
|
||||||
if(strlen($img_search->sql) > 0) {
|
if(strlen($img_search->sql) > 0) {
|
||||||
$query->append_sql("WHERE 1=1 ");
|
$query->append_sql("WHERE 1=1 ");
|
||||||
$query->append($img_search);
|
$query->append($img_search);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
|
|
|
@ -205,9 +205,9 @@ function get_thumbnail_size($orig_width, $orig_height) {
|
||||||
# $db is the connection object
|
# $db is the connection object
|
||||||
function CountExecs($db, $sql, $inputarray) {
|
function CountExecs($db, $sql, $inputarray) {
|
||||||
global $_execs;
|
global $_execs;
|
||||||
# $fp = fopen("sql.log", "a");
|
$fp = fopen("sql.log", "a");
|
||||||
# fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)."\n");
|
fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)."\n");
|
||||||
# fclose($fp);
|
fclose($fp);
|
||||||
if (!is_array($inputarray)) $_execs++;
|
if (!is_array($inputarray)) $_execs++;
|
||||||
# handle 2-dimensional input arrays
|
# handle 2-dimensional input arrays
|
||||||
else if (is_array(reset($inputarray))) $_execs += sizeof($inputarray);
|
else if (is_array(reset($inputarray))) $_execs += sizeof($inputarray);
|
||||||
|
|
Reference in a new issue