Changeset 106

Show
Ignore:
Timestamp:
01/12/06 08:02:45 (3 years ago)
Author:
sven
Message:

some sql optimisation
- count(*) is more efficient than equivalent count(fieldname) of primary key
- unlefting left joins where the right is required
- "a IN (x,y)" is easier to optimise than "a=x OR a=y"

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/_activity/index.php

    r98 r106  
    4040                 
    4141                $activities = db_query("select users.username, weblog_comments.*, weblog_posts.ident as weblogpost, weblog_posts.title as weblogtitle, weblog_posts.weblog as weblog from weblog_comments left join weblog_posts on weblog_posts.ident = weblog_comments.post_id left join users on users.ident = weblog_posts.weblog where weblog_comments.posted >= $starttime and weblog_posts.owner = $page_owner order by weblog_comments.posted desc"); 
    42                 if (sizeof($activities) > 0) { 
     42                if (is_array($activities) && sizeof($activities) > 0) { 
    4343                        foreach($activities as $activity) { 
    4444                                $commentbody = stripslashes($activity->body); 
     
    5959                 
    6060                $activities = db_query("select users.username, users.name as weblogname, weblog_comments.*, weblog_posts.weblog, weblog_posts.ident as weblogpost, weblog_posts.title as weblogtitle, weblog_posts.weblog as weblog from weblog_watchlist left join weblog_comments on weblog_comments.post_id = weblog_watchlist.weblog_post left join weblog_posts on weblog_posts.ident = weblog_comments.post_id left join users on users.ident = weblog_posts.weblog where weblog_watchlist.owner = $page_owner and weblog_comments.posted >= $starttime order by weblog_comments.posted desc"); 
    61                 if (sizeof($activities) > 0) { 
     61                if (is_array($activities) && sizeof($activities) > 0) { 
    6262                        foreach($activities as $activity) { 
    6363                                $commentbody = stripslashes($activity->body); 
  • devel/_files/rss2.php

    r92 r106  
    4646                                } else { 
    4747                                        $tag = trim($_REQUEST['tag']); 
    48                                         $files = db_query("select files.* from tags left join files on files.ident = tags.ref where files.files_owner = $page_owner and files.access = 'PUBLIC' and tags.tagtype = 'file' and tags.tag = '$tag' order by files.time_uploaded desc limit 10"); 
     48                                        $files = db_query("select files.* from tags join files on files.ident = tags.ref where files.files_owner = $page_owner and files.access = 'PUBLIC' and tags.tagtype = 'file' and tags.tag = '$tag' order by files.time_uploaded desc limit 10"); 
    4949                                } 
    5050                                if (sizeof($files) > 0) { 
  • devel/content/mainindex/content_loggedout.php

    r45 r106  
    77        $run_result .= "<p>". sprintf(gettext("<a href=\"%s\">Find others</a> with similar interests and goals."), url . "search/tags.php") . "<br /><br />"; 
    88         
    9         $users = db_query("SELECT distinct users.*, icons.filename as iconfile FROM tags LEFT JOIN users ON users.ident = tags.owner left join icons on icons.ident = users.icon WHERE (tags.tagtype = 'biography' OR tags.tagtype = 'minibio' OR tags.tagtype = 'interests')AND users.icon != -1 AND tags.access = 'PUBLIC' and users.user_type = 'person' ORDER BY rand( ) LIMIT 3 "); 
     9        $users = db_query("SELECT DISTINCT users.*, icons.filename AS iconfile FROM tags JOIN users ON users.ident = tags.owner LEFT JOIN icons ON icons.ident = users.icon WHERE tags.tagtype IN ('biography','minibio','interests') AND users.icon != -1 AND tags.access = 'PUBLIC' AND users.user_type = 'person' ORDER BY RAND() LIMIT 3"); 
    1010         
    1111        if (sizeof($users) > 0) { 
     
    3030        $run_result .= "<p>&nbsp;</p>"; 
    3131         
    32         $news = db_query("select weblog_posts.* from weblog_posts left join users on users.ident = weblog_posts.weblog where users.username = 'news' order by posted desc limit 1"); 
     32        $news = db_query("select weblog_posts.* from weblog_posts join users on users.ident = weblog_posts.weblog where users.username = 'news' order by posted desc limit 1"); 
    3333        if (sizeof($news) > 0) { 
    3434                 
  • devel/content/mainindex/content_main_index.php

    r84 r106  
    77        $run_result .= "<p>". gettext("Tell people about yourself and connect to others with similar interests and goals.") . "<br />"; 
    88         
    9         $users = db_query("SELECT distinct users.*, icons.filename as iconfile FROM tags LEFT JOIN users ON users.ident = tags.owner left join icons on icons.ident = users.icon WHERE (tags.tagtype = 'biography' OR tags.tagtype = 'minibio' OR tags.tagtype = 'interests')AND users.icon != -1 AND tags.access = 'PUBLIC' and users.user_type = 'person' ORDER BY rand( ) LIMIT 3 "); 
     9        $users = db_query("SELECT DISTINCT users.*, icons.filename AS iconfile FROM tags JOIN users ON users.ident = tags.owner LEFT JOIN icons ON icons.ident = users.icon WHERE tags.tagtype IN ('biography','minibio','interests') AND users.icon != -1 AND tags.access = 'PUBLIC' AND users.user_type = 'person' ORDER BY RAND() LIMIT 3"); 
    1010         
    1111        if (sizeof($users) > 0) { 
     
    3131        $run_result .= "<p>&nbsp;</p>"; 
    3232         
    33         $news = db_query("select weblog_posts.* from weblog_posts left join users on users.ident = weblog_posts.weblog where users.username = 'news' order by posted desc limit 1"); 
     33        $news = db_query("select weblog_posts.* from weblog_posts join users on users.ident = weblog_posts.weblog where users.username = 'news' order by posted desc limit 1"); 
    3434        if (sizeof($news) > 0) { 
    3535                 
  • devel/units/admin/admin_actions.php

    r66 r106  
    117117                                                                        } else { 
    118118                                                                                 
    119                                                                                 $exists = db_query("select count(ident) as num from users where username = '" . $new_username[$i] . "'"); 
     119                                                                                $exists = db_query("select count(*) as num from users where username = '" . $new_username[$i] . "'"); 
    120120                                                                                $exists = $exists[0]->num; 
    121121                                                                                 
  • devel/units/admin/admin_contentflags.php

    r45 r106  
    1010                $run_result .= "<form action=\"\" method=\"post\">"; 
    1111                 
    12                 $flags = db_query("select distinct url, count(ident) as totalflags from content_flags group by url order by totalflags desc"); 
     12                $flags = db_query("select distinct url, count(*) as totalflags from content_flags group by url order by totalflags desc"); 
    1313                if (sizeof($flags) > 0) { 
    1414                 
  • devel/units/admin/admin_main.php

    r97 r106  
    1010                 
    1111                // Number of users of each type 
    12                 $users = db_query("select user_type, count(ident) as numusers from users group by user_type"); 
     12                $users = db_query("select user_type, count(*) as numusers from users group by user_type"); 
    1313                if (sizeof($users) > 0) { 
    1414                        foreach($users as $user) { 
     
    2626                 
    2727                // Number of weblog posts 
    28                 $weblog_posts = db_query("select count(ident) as numposts from weblog_posts"); 
    29                 $weblog_comments = db_query("select count(ident) as numposts from weblog_comments"); 
    30                 $weblog_posts_7days = db_query("select count(ident) as numposts from weblog_posts where posted > (UNIX_TIMESTAMP() - (86400 * 7))"); 
    31                 $weblog_comments_7days = db_query("select count(ident) as numposts from weblog_comments where posted > (UNIX_TIMESTAMP() - (86400 * 7))"); 
     28                $weblog_posts = db_query("select count(*) as numposts from weblog_posts"); 
     29                $weblog_comments = db_query("select count(*) as numposts from weblog_comments"); 
     30                $weblog_posts_7days = db_query("select count(*) as numposts from weblog_posts where posted > (UNIX_TIMESTAMP() - (86400 * 7))"); 
     31                $weblog_comments_7days = db_query("select count(*) as numposts from weblog_comments where posted > (UNIX_TIMESTAMP() - (86400 * 7))"); 
    3232                $run_result .= run("templates:draw", array( 
    3333                                        'context' => 'adminTable', 
     
    3939                                 
    4040                // Number of files 
    41                 $files = db_query("select count(ident) as numfiles, sum(size) as totalsize from files"); 
    42                 $files_7days = db_query("select count(ident) as numfiles, sum(size) as totalsize from files where time_uploaded > (UNIX_TIMESTAMP() - (86400 * 7))"); 
     41                $files = db_query("select count(*) as numfiles, sum(size) as totalsize from files"); 
     42                $files_7days = db_query("select count(*) as numfiles, sum(size) as totalsize from files where time_uploaded > (UNIX_TIMESTAMP() - (86400 * 7))"); 
    4343                $run_result .= run("templates:draw", array( 
    4444                                        'context' => 'adminTable', 
  • devel/units/admin/admin_users.php

    r97 r106  
    2626                $run_result .= "</form>"; 
    2727                 
    28                 $maxusers = db_query("select count(ident) as maxusers from users where users.user_type = 'person'"); 
     28                $maxusers = db_query("select count(*) as maxusers from users where users.user_type = 'person'"); 
    2929                $maxusers = $maxusers[0]->maxusers; 
    3030                 
    31                 $users = db_query("select users.* from users where users.user_type = 'person' group by ident order by username asc limit $offset, 50"); 
     31                $users = db_query("select users.* from users where users.user_type = 'person' order by username asc limit $offset, 50"); 
    3232                 
    3333                if (sizeof($users) > 0) { 
  • devel/units/atom/isotope/storeElgg.php

    r45 r106  
    44 * isoTope: an Atom-powered web framework                             * 
    55 *                                                                    * 
    6  * storeElgg.php - Elg storage of Atom entries.                       * 
     6 * storeElgg.php - Elgg storage of Atom entries.                       * 
    77 *                Implements the storeAPI                             * 
    88 *                                                                    * 
     
    1717 
    1818/* 
    19         if ($config["storeDir"]) { 
    20         } else { 
    21               $req->addMsg("ElggStorage: not configured yet"); 
    22        
     19               if ($config["storeDir"]) { 
     20               } else { 
     21                      $req->addMsg("ElggStorage: not configured yet"); 
     22               
    2323*/ 
    2424                $req->addMsg("ElggStorage: init"); 
     
    4848                global $req; 
    4949 
    50         // TODO distinguish between blogs 
    51          
    52         $userIdent = run("users:name_to_id", ELGG_USER); 
    53         $user = run("users:instance", $userIdent); 
    54         $weblog = run("weblogs:instance", array('user_id' => $userIdent, 
    55                                                'blog_id' => $userIdent)); 
     50               // TODO distinguish between blogs 
     51                 
     52               $userIdent = run("users:name_to_id", ELGG_USER); 
     53               $user = run("users:instance", $userIdent); 
     54               $weblog = run("weblogs:instance", array('user_id' => $userIdent, 
     55                                                                                               'blog_id' => $userIdent)); 
    5656 
    57         $posts = array_slice($weblog->getPosts(), 0, $first); 
     57               $posts = array_slice($weblog->getPosts(), 0, $first); 
    5858 
    59         $feed = new AtomFeed(); 
    60         $feed->title = $weblog->getTitle(); 
     59               $feed = new AtomFeed(); 
     60               $feed->title = $weblog->getTitle(); 
    6161 
    6262                $feed->modified=0; 
    6363 
    64         if ($first >= 1) 
    65        
    66             if (sizeof($posts) > 0) 
    67            
    68                 foreach($posts as $post_id) 
    69                
    70                     // Get post object 
    71                     $post = $weblog->getPost($post_id); 
     64               if ($first >= 1) 
     65               
     66                       if (sizeof($posts) > 0) 
     67                       
     68                               foreach($posts as $post_id) 
     69                               
     70                                       // Get post object 
     71                                       $post = $weblog->getPost($post_id); 
    7272 
    73                     // New entry 
    74                     $atomEntry = new AtomFeedEntry(); 
    75                       $atomEntry->id       = $post_id; 
    76                       $atomEntry->created  = date('Y-m-d\TH:i:s', $post->getPosted()); 
    77                       $atomEntry->modified = date('Y-m-d\TH:i:s', $post->getPosted()); 
     73                                       // New entry 
     74                                       $atomEntry = new AtomFeedEntry(); 
     75                                      $atomEntry->id       = $post_id; 
     76                                      $atomEntry->created  = date('Y-m-d\TH:i:s', $post->getPosted()); 
     77                                      $atomEntry->modified = date('Y-m-d\TH:i:s', $post->getPosted()); 
    7878 
    79                     $atomEntry->link     = substr($post->getPermaLink(),0,-5); 
    80                       $atomEntry->title    = $post->getTitle(); 
    81                       $atomEntry->issued   = date('Y-m-d\TH:i:s', $post->getPosted()); 
    82                     // Personal data 
    83                     $person = new AtomPerson(); 
    84                     $person->name = $user->getName(); 
    85                     $person->url = url.ELGG_USER."/weblog"; 
    86                     $person->email = $user->getEmail(); 
    87                      
    88                     $atomEntry->author = $person; 
     79                                       $atomEntry->link     = substr($post->getPermaLink(),0,-5); 
     80                                      $atomEntry->title    = $post->getTitle(); 
     81                                      $atomEntry->issued   = date('Y-m-d\TH:i:s', $post->getPosted()); 
     82                                       // Personal data 
     83                                       $person = new AtomPerson(); 
     84                                       $person->name = $user->getName(); 
     85                                       $person->url = url.ELGG_USER."/weblog"; 
     86                                       $person->email = $user->getEmail(); 
     87                                         
     88                                       $atomEntry->author = $person; 
    8989 
    90                     $atomContent = new AtomContent(); 
    91                     $atomContent->containerType = "text"; 
    92                     $atomContent->container = "Here is the entry"; 
    93                     $atomEntry->content = $atomContent; 
    94                      
    95                       $postUrl = $this->blogDirUrl; 
    96                        
    97                       $req->addMsg("storeElgg: getAtomEntries"); 
     90                                       $atomContent = new AtomContent(); 
     91                                       $atomContent->containerType = "text"; 
     92                                       $atomContent->container = "Here is the entry"; 
     93                                       $atomEntry->content = $atomContent; 
     94                                         
     95                                      $postUrl = $this->blogDirUrl; 
     96                                       
     97                                      $req->addMsg("storeElgg: getAtomEntries"); 
    9898 
    99                     // TODO modify service url for this post 
     99                                       // TODO modify service url for this post 
    100100 
    101                     // Add the entry to the feed 
    102                     array_push($feed->entries, $atomEntry); 
    103                
    104            
    105        
     101                                       // Add the entry to the feed 
     102                                       array_push($feed->entries, $atomEntry); 
     103                               
     104                       
     105               
    106106                return $feed; 
    107107        } 
  • devel/units/communities/communities_access_level_check.php

    r45 r106  
    44                $commnum = (int) substr($parameter, 9, 15); 
    55                $result = db_query("select friends.owner from friends 
    6                                                                                                  left join users on users.ident = friends.friend 
     6                                                                                                 join users on users.ident = friends.friend 
    77                                                                                                 where users.user_type = 'community' 
    88                                                                                                 and users.ident = $commnum 
  • devel/units/communities/communities_access_level_sql_check.php

    r45 r106  
    55                if (logged_on) { 
    66                         
    7                         $communities = db_query("select users.* from friends left join users on users.ident = friends.friend where users.user_type = 'community' and users.owner <> " . $_SESSION['userid'] . " and friends.owner = " . $_SESSION['userid']); 
     7                        $communitieslist = array(); 
     8                         
     9                        $communities = db_query("select users.* from friends join users on users.ident = friends.friend where users.user_type = 'community' and users.owner <> " . $_SESSION['userid'] . " and friends.owner = " . $_SESSION['userid']); 
    810                        if (sizeof($communities) > 0) { 
    911                                foreach($communities as $community) { 
    10                                         $run_result .= "or access = \"community" . $community->ident . "\" "
     12                                        $communitieslist[] = $community->ident
    1113                                } 
    1214                        } 
     
    1416                        if (sizeof($communities) > 0) { 
    1517                                foreach($communities as $community) { 
    16                                         $run_result .= "or access = \"community" . $community->ident . "\" "
     18                                        $communitieslist[] = $community->ident
    1719                                } 
    1820                        } 
    19                                                  
     21                        if (count($communitieslist)) { 
     22                                $communitieslist = array_unique($communitieslist); 
     23                                $run_result .= " or access IN ('community" . implode("', 'community", $communitieslist) . "') "; 
     24                        } 
    2025                } 
    2126 
  • devel/units/communities/communities_actions.php

    r77 r106  
    2020                                        } else { 
    2121                                                $username = strtolower(trim($_REQUEST['comm_username'])); 
    22                                                 $usernametaken = db_query("select count(ident) as taken from users where username = '$username'"); 
     22                                                $usernametaken = db_query("select count(*) as taken from users where username = '$username'"); 
    2323                                                $usernametaken = $usernametaken[0]->taken; 
    2424                                                if ($usernametaken > 0) { 
  • devel/units/communities/communities_edit.php

    r84 r106  
    1010                 
    1111                $result = db_query("select users.*, friends.ident as friendident from friends 
    12                                                                         left join users on users.ident = friends.friend 
     12                                                                        join users on users.ident = friends.friend 
    1313                                                                        where friends.owner = $user_id and users.user_type = 'community'"); 
    1414                                                                         
  • devel/units/communities/permissions_check.php

    r45 r106  
    2020                                                                                        } 
    2121                                                                                        if ($run_result != true) { 
    22                                                                                                 $result = db_query("select count(users.ident) as num from friends 
    23                                                                                                                                                         left join users on users.ident = friends.friend 
     22                                                                                                $result = db_query("select count(*) as num from friends 
     23                                                                                                                                                        join users on users.ident = friends.friend 
    2424                                                                                                                                                        where users.ident = $page_owner 
    2525                                                                                                                                                        and friends.owner = ". $_SESSION['userid'] . " 
     
    5656                                                                                        } 
    5757                                                                                        if ($run_result != true) { 
    58                                                                                                 $result = db_query("select count(users.ident) as num from friends 
    59                                                                                                                                                         left join users on users.ident = friends.friend 
     58                                                                                                $result = db_query("select count(*) as num from friends 
     59                                                                                                                                                        join users on users.ident = friends.friend 
    6060                                                                                                                                                        where users.ident = $owner 
    6161                                                                                                                                                        and friends.owner = ". $_SESSION['userid'] . " 
  • devel/units/communities/user_info_menu_text.php

    r45 r106  
    99                         
    1010                        if (run("users:type:get", $user_id) == "community") { 
    11                                 $result = db_query("select count(users.ident) as friend from friends  
    12                                                                         left join users on users.ident = friends.friend 
     11                                $result = db_query("select count(*) as friend from friends  
     12                                                                        join users on users.ident = friends.friend 
    1313                                                                        where friends.owner = " . $_SESSION['userid'] . " 
    14                                                                           and friends.friend = $user_id"); 
     14                                                                         and friends.friend = $user_id"); 
    1515                                $result = $result[0]->friend; 
    1616                                if ($result == 0) { 
  • devel/units/db/library.php

    r94 r106  
    11<?php 
    2  
    3 /* 
    4 * TODO: This could probably do with using the $db_connection variable in the mysql functions, 
    5 * as PHP can be a bit arbitrary in its choice of db session. Would also be required for a  
    6 * replicated mysql system, which could be a future need for large user bases. 
    7 * Not actually running a test copy of Elgg atm so dunno what scope $db_connection's in. 
    8 * - Sven 
    9 */ 
    102 
    113        // Database library functions 
     
    168                        global $querynum; 
    179                        global $querycache; 
     10                        global $db_connection; 
    1811                         
    1912                        /*if (isset($querycache[$sql_query])) { 
     
    2922                        // echo "<b>" . $run_context . "</b>&nbsp;&nbsp;" . $sql_query . "<br />"; 
    3023                        if ($sql_query != "") { 
    31                                 // echo "<!-- $sql_query -->\n"; 
    32                                 if ($result = @mysql_query($sql_query)) { 
     24                                if ($result = @mysql_query($sql_query, $db_connection)) { 
    3325                                        $data = array(); 
    3426                                        if (!is_bool($result)) { 
     
    4234                                } else { 
    4335                                        if (ELGG_DEBUG) { 
    44                                                 echo $sql_query . " :: " . @mysql_error() . "<br />\n"; 
     36                                                echo $sql_query . " :: " . @mysql_error($db_connection) . "<br />\n"; 
    4537                                        } 
    4638                                        $querycache[$sql_query] = FALSE; 
     
    5446        // Rows affected by the last MySQL transaction 
    5547                function db_affected_rows() { 
    56                         return @mysql_affected_rows(); 
     48                        global $db_connection; 
     49                        return @mysql_affected_rows($db_connection); 
    5750                } 
    5851                 
    5952        // Returns the ID of the last MySQL transaction 
    6053                function db_id() { 
    61                         return @mysql_insert_id(); 
     54                        global $db_connection; 
     55                        return @mysql_insert_id($db_connection); 
    6256                } 
    6357 
  • devel/units/display/function_output_field_display.php

    r85 r106  
    6161                                                        $where = run("users:access_level_sql_where",$_SESSION['userid']); 
    6262                                                        foreach($keyword_list as $key => $list_item) { 
    63                                                                 $numberofkeywords = db_query("select count(ident) as number from profile_data where ($where) and name = '".$parameter[2]."' and value like \"%[[".$list_item."]]%\""); 
     63                                                                $numberofkeywords = db_query("select count(*) as number from profile_data where ($where) and name = '".$parameter[2]."' and value like \"%[[".$list_item."]]%\""); 
    6464                                                                $number = $numberofkeywords[0]->number; 
    6565                                                                if ($number > 1) { 
     
    8484                                                                        $keywords .= ", "; 
    8585                                                                } 
    86                                                                 $numberoftags = db_query("select count(ident) as number from tags where tag = '".$tag->tag."'"); 
     86                                                                $numberoftags = db_query("select count(*) as number from tags where tag = '".$tag->tag."'"); 
    8787                                                                $numberoftags = $numberoftags[0]->number; 
    8888                                                                if ($numberoftags > 1) { 
  • devel/units/files/files_init.php

    r45 r106  
    2929                if (isset($_REQUEST['folder'])) { 
    3030                        $folder = (int) $_REQUEST['folder']; 
    31                         $result = db_query("select count(ident) as x from file_folders where ident = $folder and files_owner = $owner"); 
     31                        $result = db_query("select count(*) as x from file_folders where ident = $folder and files_owner = $owner"); 
    3232                        if ($result[0]->x < 1) { 
    3333                                $folder = -1; 
  • devel/units/files/files_user_info_menu.php

    r84 r106  
    77                if ($page_owner != -1 && $page_owner != $_SESSION['userid']) { 
    88                 
    9                         $posts = db_query("select count(ident) as x from files where (".run("users:access_level_sql_where",$profile_id).") and files_owner = $profile_id"); 
     9                        $posts = db_query("select count(*) as x from files where (".run("users:access_level_sql_where",$profile_id).") and files_owner = $profile_id"); 
    1010                        $posts = $posts[0]->x; 
    1111                 
  • devel/units/files/function_search.php

    r85 r106  
    1515                $folder_refs = db_query("select ref from tags where $searchline_folders"); 
    1616                $searchline = ""; 
     17                $searchlist = array(); 
    1718                if (sizeof($folder_refs) > 0) { 
    1819                        foreach($folder_refs as $folder) { 
    19                                 if ($searchline != "") { 
    20                                         $searchline .= " or "; 
    21                                 } 
    22                                 $searchline .= "file_folders.ident = " . $folder->ref; 
     20                                $searchlist[] = $folder->ref; 
    2321                        } 
     22                        $searchline = " file_folders.ident IN (" . implode(", ", $searchlist) . ") "; 
    2423                        $folders = db_query("select file_folders.name, users.name as userfullname, users.username, file_folders.ident from file_folders  
    25                                                                 left join users on users.ident = file_folders.owner where ($searchline)  
     24                                                                join users on users.ident = file_folders.owner where ($searchline)  
    2625                                                                order by name asc"); 
    2726                        $run_result .= "<h2>" . sprintf(gettext("Folders owned by '%s' in category '%s'"),stripslashes($folders[0]->userfullname),$parameter[1])."</h2>\n"; 
     
    4140                } 
    4241                $searchline = ""; 
     42                $searchlist = array(); 
    4343                if (sizeof($file_refs) > 0) { 
    4444                        foreach($file_refs as $file) { 
    45                                 if ($searchline != "") { 
    46                                         $searchline .= " or "; 
    47                                 } 
    48                                 $searchline .= "files.ident = " . $file->ref; 
     45                                $searchlist[] = $file->ref; 
    4946                        } 
     47                        $searchline = " files.ident IN (" . implode(", ", $searchlist) . ") "; 
    5048                        $files = db_query("select files.*, users.username, users.name as userfullname from files 
    51                                                                 left join users on users.ident = files.owner where ($searchline)  
     49                                                                join users on users.ident = files.owner where ($searchline)  
    5250                                                                order by title asc") 
    5351                                                                or die(mysql_error()); 
     
    7169                        $run_result .= "<p><small>[ <a href=\"".url.$files[0]->username . "/files/rss/" . $parameter[1] . "\">".sprintf(gettext("RSS feed for files owned by %s"), stripslashes($files[0]->userfullname)) . " in category '".$parameter[1]."'</a> ]</small></p>\n"; 
    7270                } 
    73                 $searchline = "(tagtype = 'file' or tagtype = 'folder') and tag = '".addslashes($parameter[1])."'"; 
     71                $searchline = " tagtype IN ('file','folder') and tag = '".addslashes($parameter[1])."'"; 
    7472                $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") and " . $searchline; 
    7573                $searchline = str_replace("owner","tags.owner",$searchline); 
    76                 $sql = "select distinct users.* from tags left join users on users.ident = tags.owner where ($searchline)"; 
     74                $sql = "select distinct users.* from tags join users on users.ident = tags.owner where ($searchline)"; 
    7775              &nbs