Refactoring: free few sql results
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@247 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
4aaef1823e
commit
c0e46287e4
6 changed files with 47 additions and 15 deletions
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue