/** * Returns suggestions for topics from this user or their friends * * @param int $uid * @param array $friends * @return array */ public static function getSuggestions($uid, array $friends) { if (!isset($uid) && !isset($friends)) { print "UID ({$uid}) and Friends({$friends}) must both be set!"; return; } $friends[] = $uid; $friends_list = implode(',', $friends); $sql = "SELECT * FROM suggestions WHERE api_key ='" . Config::$api_key . "'"; if (strlen($friends_list) > 0) { $sql .= " AND owneruid IN ({$friends_list})"; } $sql .= " ORDER BY topic, sid"; error_log("executing sql: {$sql}"); $suggestionsResults = mysql_query($sql, SuggestionUtils::get_db_conn()) or print mysql_error(); $displaySuggestions = array(); while ($row = mysql_fetch_assoc($suggestionsResults)) { $displaySuggestions[] = $row; } return $displaySuggestions; }
/** * Returns all the topics for this user * * @param array $uids * @return array */ public static function getTopics(array $friends) { $friends_list = implode(',', $friends); $sql = "SELECT DISTINCT topic, owneruid FROM suggestions"; if (strlen($friends_list) > 0) { $sql .= " WHERE owneruid IN ({$friends_list})"; } $res = mysql_query($sql, SuggestionUtils::get_db_conn()); $ret = array(); while ($row = mysql_fetch_assoc($res)) { $ret[] = $row; } return $ret; }