]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
sql optimization: fetch all tags at once
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sat, 20 Feb 2010 11:16:34 +0000 (11:16 +0000)
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sat, 20 Feb 2010 11:16:34 +0000 (11:16 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@668 b3834d28-1941-0410-a4f8-b48e95affb8f

src/SemanticScuttle/Service/Bookmark.php
src/SemanticScuttle/Service/Bookmark2Tag.php

index c7bfb3bbbaeb5a4ac2640dac27f44f53c6921e20..9d72023aa872f9888aee619d04651aec16292628 100644 (file)
@@ -804,10 +804,17 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
         $total = $row['total'];
         $this->db->sql_freeresult($totalresult);
 
-        $bookmarks = array();
-        while ($row = & $this->db->sql_fetchrow($dbresult)) {
-            $row['tags'] = $b2tservice->getTagsForBookmark(intval($row['bId']));
-            $bookmarks[] = $row;
+        $bookmarks   = array();
+        $bookmarkids = array();
+        while ($row = $this->db->sql_fetchrow($dbresult)) {
+            $bookmarks[]   = $row;
+            $bookmarkids[] = $row['bId'];
+        }
+        if (count($bookmarkids)) {
+            $tags = $b2tservice->getTagsForBookmarks($bookmarkids);
+            foreach ($bookmarks as &$bookmark) {
+                $bookmark['tags'] = $tags[$bookmark['bId']];
+            }
         }
 
         $this->db->sql_freeresult($dbresult);
index 770b1d92f6ec702e925c21fd15516b335176c3d3..d6c0e5897f5a4f2b30c85ad6ba266026ffb8a50c 100644 (file)
@@ -321,6 +321,8 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
                 '', __LINE__, __FILE__, $query
             );
             return false;
+        } else if (count($bookmarkids) == 0) {
+            return array();
         }
 
         $sql = '';