first sql optimization: fetch countOthers() for all bookmarks at once instead of each single

git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@661 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
cweiske 2010-02-20 11:06:12 +00:00
parent 05c2369507
commit fe522e5719

View file

@ -216,7 +216,13 @@ if($currenttag!= '') {
<ol <?php echo ($start > 0 ? ' start="'. ++$start .'"' : ''); ?> <ol <?php echo ($start > 0 ? ' start="'. ++$start .'"' : ''); ?>
id="bookmarks"> id="bookmarks">
<?php <?php
$addresses = array();
foreach ($bookmarks as $key => &$row) {
$addresses[$row['bId']] = $row['bAddress'];
}
$otherCounts = $bookmarkservice->countOthers($addresses);
foreach ($bookmarks as $key => &$row) { foreach ($bookmarks as $key => &$row) {
switch ($row['bStatus']) { switch ($row['bStatus']) {
case 0: case 0:
@ -261,7 +267,7 @@ if($currenttag!= '') {
// Udders! // Udders!
if (!isset($hash)) { if (!isset($hash)) {
$others = $bookmarkservice->countOthers($row['bAddress']); $others = $otherCounts[$row['bAddress']];
$ostart = '<a href="'. createURL('history', $row['bHash']) .'">'; $ostart = '<a href="'. createURL('history', $row['bHash']) .'">';
$oend = '</a>'; $oend = '</a>';
switch ($others) { switch ($others) {