From e88a078b463618a9709336c06dd7b25b723fb484 Mon Sep 17 00:00:00 2001
From: Jonathan Pugh <web@thinkdrop.net>
Date: Thu, 17 Mar 2011 21:45:21 +0000
Subject: [PATCH] Patch for #1095524: removing db_fetch_object()s

---
 flag_friend.module |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git flag_friend.module flag_friend.module
index c88f3b7..01b7ceb 100644
--- flag_friend.module
+++ flag_friend.module
@@ -137,8 +137,10 @@ function flag_friend_get_flags($flag, $content_id, $reset = NULL) {
     $flags = flag_get_flags($flag->content_type);
     $flagged_content[$uid][$content_type][$content_id] = array();
     // get flags with messages
-    $result = db_query("SELECT fc.*, ffm.message FROM {flag_content} fc LEFT JOIN {flag_friend_message} ffm ON ffm.fcid = fc.fcid WHERE fc.fid = :fc.fid AND fc.content_type = :fc.content_type AND fc.content_id = :fc.content_id", array(':fc.fid' => $flag->fid, ':fc.content_type' => $content_type, ':fc.content_id' => $content_id));
-    while ($new_flag = db_fetch_object($result)) {
+    $results = db_query("SELECT fc.*, ffm.message FROM {flag_content} fc LEFT JOIN {flag_friend_message} ffm ON ffm.fcid = fc.fcid WHERE fc.fid = :fc.fid AND fc.content_type = :fc.content_type AND fc.content_id = :fc.content_id", array(':fc.fid' => $flag->fid, ':fc.content_type' => $content_type, ':fc.content_id' => $content_id))->fetchAll();
+    
+    
+    foreach ($result as $new_flag) {
       $fcid = flag_friend_get_fcid($flag, $content_id, $new_flag->uid);
       $flagged_content[$uid][$content_type][$content_id][$fcid] = $new_flag;
       $flagged_content[$uid][$content_type][$content_id][$fcid]->user = user_load($new_flag->uid);
@@ -163,8 +165,8 @@ function flag_friend_get_friends($uid, $reset = NULL) {
 
   if (!isset($friends[$uid]) || $reset) {
     $friends[$uid] = array();
-    $result = db_query("SELECT * FROM {flag_friend} WHERE uid = :uid OR friend_uid = :uid", array(':uid' => $uid, ':friend_uid' => $uid));
-    while ($friend = db_fetch_object($result)) {
+    $results = db_query("SELECT * FROM {flag_friend} WHERE uid = :uid OR friend_uid = :friend_uid", array(':uid' => $uid, ':friend_uid' => $uid))->fetchAll();
+    foreach ($results as $friend) {
       // if the current user is in the uid column
       if ($friend->uid == $uid) {
         // load the friend_uid
-- 
1.6.3.3

