summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-02-03 15:32:23 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-02-03 15:32:23 +0000
commitc0e46287e41ac5be4c4832c915c8e2ba78b9a1d5 (patch)
tree98aef584a8d4b91c5a618bbbfa11953cba4ad9c2 /services
parent4aaef1823e5e37f02bc18078ccb67217b8cdbcb7 (diff)
downloadsemanticscuttle-c0e46287e41ac5be4c4832c915c8e2ba78b9a1d5.tar.gz
semanticscuttle-c0e46287e41ac5be4c4832c915c8e2ba78b9a1d5.tar.bz2
Refactoring: free few sql results
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@247 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'services')
-rw-r--r--services/bookmark2tagservice.php12
-rw-r--r--services/bookmarkservice.php22
-rw-r--r--services/searchhistoryservice.php5
-rw-r--r--services/tag2tagservice.php12
-rw-r--r--services/tagcacheservice.php4
-rw-r--r--services/userservice.php7
6 files changed, 47 insertions, 15 deletions
diff --git a/services/bookmark2tagservice.php b/services/bookmark2tagservice.php
index 26abf4a..63f3d57 100644
--- a/services/bookmark2tagservice.php
+++ b/services/bookmark2tagservice.php
@@ -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) {
diff --git a/services/bookmarkservice.php b/services/bookmarkservice.php
index 4b000b4..1d72bc8 100644
--- a/services/bookmarkservice.php
+++ b/services/bookmarkservice.php
@@ -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) {
diff --git a/services/searchhistoryservice.php b/services/searchhistoryservice.php
index 72ea825..91457e8 100644
--- a/services/searchhistoryservice.php
+++ b/services/searchhistoryservice.php
@@ -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'];
}
diff --git a/services/tag2tagservice.php b/services/tag2tagservice.php
index 01df423..1547daf 100644
--- a/services/tag2tagservice.php
+++ b/services/tag2tagservice.php
@@ -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;
}
diff --git a/services/tagcacheservice.php b/services/tagcacheservice.php
index bb82864..ed2eefc 100644
--- a/services/tagcacheservice.php
+++ b/services/tagcacheservice.php
@@ -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;
}
diff --git a/services/userservice.php b/services/userservice.php
index 21b9136..7f0382d 100644
--- a/services/userservice.php
+++ b/services/userservice.php
@@ -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) ) {
$rows[] = $row;
}
-
+ $this->db->sql_freeresult($dbresult);
return $rows;
}