]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Refactoring: free few sql results
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Tue, 3 Feb 2009 15:32:23 +0000 (15:32 +0000)
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Tue, 3 Feb 2009 15:32:23 +0000 (15:32 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@247 b3834d28-1941-0410-a4f8-b48e95affb8f

services/bookmark2tagservice.php
services/bookmarkservice.php
services/searchhistoryservice.php
services/tag2tagservice.php
services/tagcacheservice.php
services/userservice.php

index 26abf4a99904d46b69decf39feb62fbeb1e86ad0..63f3d572edaaf86082189f5e9c743adf71ed74d8 100644 (file)
@@ -219,7 +219,7 @@ class Bookmark2TagService {
                while ($row =& $this->db->sql_fetchrow($dbresult)) {
                        $tags[] = $row['tag'];
                }
-
+               $this->db->sql_freeresult($dbresult);
                return $tags;
        }
 
@@ -246,6 +246,7 @@ class Bookmark2TagService {
                }
 
                $output = $this->db->sql_fetchrowset($dbresult);
+               $this->db->sql_freeresult($dbresult);
                return $output;
        }
 
@@ -292,6 +293,7 @@ class Bookmark2TagService {
                        return false;
                }
                $output = $this->db->sql_fetchrowset($dbresult);
+               $this->db->sql_freeresult($dbresult);
                return $output;
        }
 
@@ -321,6 +323,7 @@ class Bookmark2TagService {
                        return false;
                }
                $output = $this->db->sql_fetchrowset($dbresult);
+               $this->db->sql_freeresult($dbresult);
                return $output;
        }
 
@@ -350,6 +353,7 @@ class Bookmark2TagService {
                }
 
                $output = $this->db->sql_fetchrowset($dbresult);
+               $this->db->sql_freeresult($dbresult);
                return $output;
        }
 
@@ -363,10 +367,12 @@ class Bookmark2TagService {
 
                if ($row =& $this->db->sql_fetchrow($dbresult)) {
                        if ($row['tCount'] > 0) {
-                               return true;
+                               $output = true;
                        }
                }
-               return false;
+               $output = false;
+               $this->db->sql_freeresult($dbresult);
+               return $output;
        }
 
        function renameTag($userid, $old, $new, $fromApi = false) {
index 4b000b4949b300603280cb4e08912660eea925f8..1d72bc8fdf5be7f7d9f3a5d1c5398c92719a2c59 100644 (file)
@@ -32,10 +32,12 @@ class BookmarkService {
                }
 
                if ($row =& $this->db->sql_fetchrow($dbresult)) {
-                       return $row;
+                       $output = $row;
                } else {
-                       return false;
+                       $output =  false;
                }
+               $this->db->sql_freeresult($dbresult);
+               return $output;
        }
 
        function & getBookmark($bid, $include_tags = false) {
@@ -52,10 +54,12 @@ class BookmarkService {
                                $b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
                                $row['tags'] = $b2tservice->getTagsForBookmark($bid);
                        }
-                       return $row;
+                       $output = $row;                 
                } else {
-                       return false;
+                       $output = false;
                }
+               $this->db->sql_freeresult($dbresult);
+               return $output;
        }
 
        function getBookmarkByAddress($address) {
@@ -103,7 +107,9 @@ class BookmarkService {
                if (!($dbresult = & $this->db->sql_query($sql))) {
                        message_die(GENERAL_ERROR, 'Could not get vars', '', __LINE__, __FILE__, $sql, $this->db);
                }
-               return ($this->db->sql_fetchfield(0, 0) > 0);
+               $ouput = ($this->db->sql_fetchfield(0, 0) > 0); 
+               $this->db->sql_freeresult($dbresult);
+               return $output;
        }
 
        // Adds a bookmark to the database.
@@ -390,6 +396,7 @@ class BookmarkService {
                        $bookmarks[] = $row;
                }
 
+               $this->db->sql_freeresult($dbresult);
                $output = array ('bookmarks' => $bookmarks, 'total' => $total);
                return $output;
        }
@@ -451,7 +458,10 @@ class BookmarkService {
                if (!($dbresult = & $this->db->sql_query($sql))) {
                        message_die(GENERAL_ERROR, 'Could not get vars', '', __LINE__, __FILE__, $sql, $this->db);
                }
-               return $this->db->sql_fetchfield(0, 0) - 1;
+               
+               $output = $this->db->sql_fetchfield(0, 0) - 1;
+               $this->db->sql_freeresult($dbresult);
+               return $output;
        }
 
        function normalize($address) {
index 72ea825b6b0a04996b6369bd2a75580e669c0246..91457e8d85b08ac93386c79ea9590f330786da9e 100644 (file)
@@ -72,16 +72,17 @@ class SearchHistoryService {
                while ($row = & $this->db->sql_fetchrow($dbresult)) {
                        $searches[] = $row;
                }
+               $this->db->sql_freeresult($dbresult);
                return $searches;
        }
 
        function countSearches() {
                $sql = 'SELECT COUNT(*) AS `total` FROM '. $this->getTableName();
-               if (!($result = & $this->db->sql_query($sql)) || (!($row = & $this->db->sql_fetchrow($result)))) {
+               if (!($dbresult = & $this->db->sql_query($sql)) || (!($row = & $this->db->sql_fetchrow($dbresult)))) {
                        message_die(GENERAL_ERROR, 'Could not get total searches', '', __LINE__, __FILE__, $sql, $this->db);
                        return false;
                }
-
+               $this->db->sql_freeresult($dbresult);
                return $row['total'];
        }
 
index 01df423b914e9f8fdac32eeb5fa440cbc37d570d..1547dafd70a0dbc8871e4105a8aa6277635707bd 100644 (file)
@@ -88,6 +88,7 @@ class Tag2TagService {
                        //$output = array_unique($output); // remove duplication
                }
 
+               $this->db->sql_freeresult($dbresult);
                return $output;
        }
 
@@ -209,7 +210,9 @@ class Tag2TagService {
                        message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db);
                        return false;
                }
-               return $this->db->sql_fetchrowset($dbresult);
+               $output = $this->db->sql_fetchrowset($dbresult);
+               $this->db->sql_freeresult($dbresult);
+               return $output;
        }
 
        function getMenuTags($uId) {
@@ -232,7 +235,9 @@ class Tag2TagService {
                                message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db);
                                return false;
                        }
-                       return $this->db->sql_fetchrowset($dbresult);
+                       $output = $this->db->sql_fetchrowset($dbresult);
+                       $this->db->sql_freeresult($dbresult);
+                       return $output;
                }
        }
 
@@ -284,7 +289,8 @@ class Tag2TagService {
 
                // Update stats and cache
                $this->update($tag1, $tag2, $relationType, $uId);
-
+               
+               $this->db->sql_freeresult($dbresult);
                return true;
        }
 
index bb828649fa03a3e15ce6b7f5f38fbb384ce2ac09..ed2eefc1a1bfc3c5e9bef8f6f0fc2d4444a0c429 100644 (file)
@@ -49,6 +49,7 @@ class TagCacheService {
                        $output[] = $row['tag'];
                }
 
+               $this->db->sql_freeresult($dbresult);
                return $output;
        }
 
@@ -257,6 +258,7 @@ class TagCacheService {
                }
 
                $row = $this->db->sql_fetchrow($dbresult);
+               $this->db->sql_freeresult($dbresult);
                return $row['tag'];
        }
 
@@ -289,6 +291,8 @@ class TagCacheService {
                foreach($rowset as $row) {
                        $output[] = $row['tag'];
                }
+               
+               $this->db->sql_freeresult($dbresult);
                return $output;
        }
 
index 21b91366984b3bce8bd3c031b3bfe0696590f3c5..7f0382de9a928c856ae6764b99d2af0b2d5e8990 100644 (file)
@@ -73,6 +73,7 @@ class UserService {
                while ($row = & $this->db->sql_fetchrow($dbresult)) {
                        $users[] = $row;
                }
+               $this->db->sql_freeresult($dbresult);
                return $users;
        }
 
@@ -89,6 +90,7 @@ class UserService {
                while ($row = & $this->db->sql_fetchrow($dbresult)) {
                        $users[] = new User($row[$this->getFieldName('primary')], $row[$this->getFieldName('username')]);
                }
+               $this->db->sql_freeresult($dbresult);
                return $users;
        }
 
@@ -238,6 +240,7 @@ class UserService {
 
                        if ($row = $this->db->sql_fetchrow($dbresult)) {
                                $_SESSION[$this->getSessionKey()] = $row[$this->getFieldName('primary')];
+                               $this->db->sql_freeresult($dbresult);
                                return $_SESSION[$this->getSessionKey()];
                        }
                }
@@ -259,6 +262,7 @@ class UserService {
                                $cookie = $id .':'. md5($username.$password);
                                setcookie($this->cookiekey, $cookie, time() + $this->cookietime, '/');
                        }
+                       $this->db->sql_freeresult($dbresult);
                        return true;
                } else {
                        return false;
@@ -314,6 +318,7 @@ class UserService {
                while ($row =& $this->db->sql_fetchrow($dbresult)) {
                        $arrWatch[] = $row[$this->getFieldName('username')];
                }
+               $this->db->sql_freeresult($dbresult);
                return $arrWatch;
        }
 
@@ -422,7 +427,7 @@ class UserService {
                while ( $row = $this->db->sql_fetchrow($dbresult) ) {\r
                        $rows[] = $row;\r
                }\r
-\r
+               $this->db->sql_freeresult($dbresult);\r
                return $rows;\r
        }\r
 \r