aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-02-20 11:16:34 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-02-20 11:16:34 +0000
commit6a6cba1a4d61d42bd93fb385f576d299bd99cc59 (patch)
tree4733e0ef3ea7d9d6f0ec5cf7e30d036535ac3ff1 /src
parent3e9c2cd0a57d798bb7cbcf89575cbc0199e0d2e5 (diff)
downloadsemanticscuttle-6a6cba1a4d61d42bd93fb385f576d299bd99cc59.tar.gz
semanticscuttle-6a6cba1a4d61d42bd93fb385f576d299bd99cc59.tar.bz2
sql optimization: fetch all tags at once
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@668 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'src')
-rw-r--r--src/SemanticScuttle/Service/Bookmark.php15
-rw-r--r--src/SemanticScuttle/Service/Bookmark2Tag.php2
2 files changed, 13 insertions, 4 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index c7bfb3b..9d72023 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -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);
diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php
index 770b1d9..d6c0e58 100644
--- a/src/SemanticScuttle/Service/Bookmark2Tag.php
+++ b/src/SemanticScuttle/Service/Bookmark2Tag.php
@@ -321,6 +321,8 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
'', __LINE__, __FILE__, $query
);
return false;
+ } else if (count($bookmarkids) == 0) {
+ return array();
}
$sql = '';