summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/class/artist.class.php12
-rw-r--r--lib/search.php40
2 files changed, 37 insertions, 15 deletions
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index 534281d6..5f9267b3 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -234,10 +234,7 @@ class Artist {
$check_exists_qstring = "SELECT name FROM artist WHERE id='" . sql_escape($newid) . "'";
$check_exists_query = mysql_query($check_exists_qstring, dbh());
- if (mysql_num_rows($check_exists_query)) {
-
- // Get the name, for use in output
- $check_exists_result = mysql_fetch_assoc($check_exists_query);
+ if ($check_exists_results = mysql_fetch_assoc($check_exists_query)) {
$NewName = $check_exists_result['name'];
@@ -246,19 +243,16 @@ class Artist {
"WHERE artist='" . sql_escape($this->id) . "'";
$db_results = mysql_query($sql, dbh());
- $num_stats_changed = $catalog->merge_stats("artist",$this->id,$newid);
+ $num_stats_changed = $catalog->merge_stats('artist',$this->id,$newid);
- /* If we've done the merege we need to clean up
+ /* If we've done the merege we need to clean up */
$catalog->clean_artists();
$catalog->clean_albums();
-
}
-
else {
$GLOBALS['error']->add_error('general',"Error: Invalid Artist ID");
return false;
}
-
} // merge
diff --git a/lib/search.php b/lib/search.php
index ac5a0873..8484c71f 100644
--- a/lib/search.php
+++ b/lib/search.php
@@ -72,7 +72,8 @@ function run_search($data) {
$results = call_user_func($function_name,$search,$operator,$method,$limit);
return $results;
}
- default:
+ break;
+ default:
$results = search_song($search,$operator,$method,$limit);
return $results;
break;
@@ -93,33 +94,60 @@ function search_song($data,$operator,$method,$limit) {
/* Generate BASE SQL */
$base_sql = "SELECT DISTINCT(song.id) FROM song";
+
$where_sql = '';
$table_sql = ',';
+ $join_sql = '';
if ($limit > 0) {
$limit_sql = " LIMIT $limit";
}
-
foreach ($data as $type=>$value) {
/* Create correct Value statement based on method */
+
$value_string = str_replace("__",$value,$method);
switch ($type) {
+ case 'all': /* artist, title, and album, anyway.. */
+ $value_words = explode(' ', $value);
+ $where_sql .= " ( ";
+ $ii == 0;
+ foreach($value_words as $word)
+ {
+ if($ii++ > 0)
+ $where_sql .= " AND ";
+ $where_sql .= "
+ (
+ song.title LIKE '%$word%' OR
+ album2.name LIKE '%$word%' OR
+ artist2.name LIKE '%$word%' OR
+ genre2.name LIKE '%$word%' OR
+ song.year LIKE '%$word%' OR
+ song.file LIKE '%$word%'
+ ) ";
+ }
+ $where_sql .= " ) $operator";
+ $join_sql .= "song.album=album2.id AND song.artist=artist2.id AND song.genre=genre2.id AND ";
+ $table_sql .= "album as album2,artist as artist2, genre as genre2";
+ break;
case 'title':
$where_sql .= " song.title $value_string $operator";
break;
case 'album':
- $where_sql .= " ( song.album=album.id AND album.name $value_string ) $operator";
+ $where_sql .= " album.name $value_string $operator";
+ $join_sql .= "song.album=album.id AND ";
$table_sql .= "album,";
break;
case 'artist':
- $where_sql .= " ( song.artist=artist.id AND artist.name $value_string ) $operator";
+ $where_sql .= " artist.name $value_string $operator";
+ $join_sql .= "song.artist=artist.id AND ";
$table_sql .= "artist,";
break;
case 'genre':
- $where_sql .= " ( song.genre=genre.id AND genre.name $value_string ) $operator";
+ $where_sql .= " genre.name $value_string $operator";
+ $join_qsl .= "song.genre=genre.id AND ";
$table_sql .= "genre,";
break;
case 'year':
@@ -149,7 +177,7 @@ function search_song($data,$operator,$method,$limit) {
$table_sql = rtrim($table_sql,',');
$where_sql = rtrim($where_sql,$operator);
- $sql = $base_sql . $table_sql . " WHERE" . $where_sql . $limit_sql;
+ $sql = $base_sql . $table_sql . " WHERE " . $join_sql . "(" . $where_sql . ")" . $limit_sql;
$db_results = mysql_query($sql, dbh());