sql optimization: fetch all tags at once
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@668 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
3e9c2cd0a5
commit
6a6cba1a4d
2 changed files with 13 additions and 4 deletions
|
@ -805,9 +805,16 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
|
||||||
$this->db->sql_freeresult($totalresult);
|
$this->db->sql_freeresult($totalresult);
|
||||||
|
|
||||||
$bookmarks = array();
|
$bookmarks = array();
|
||||||
while ($row = & $this->db->sql_fetchrow($dbresult)) {
|
$bookmarkids = array();
|
||||||
$row['tags'] = $b2tservice->getTagsForBookmark(intval($row['bId']));
|
while ($row = $this->db->sql_fetchrow($dbresult)) {
|
||||||
$bookmarks[] = $row;
|
$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);
|
$this->db->sql_freeresult($dbresult);
|
||||||
|
|
|
@ -321,6 +321,8 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
|
||||||
'', __LINE__, __FILE__, $query
|
'', __LINE__, __FILE__, $query
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
} else if (count($bookmarkids) == 0) {
|
||||||
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = '';
|
$sql = '';
|
||||||
|
|
Loading…
Reference in a new issue