示例#1
0
 public FollowData(Follow follow, string name, string type, string email, string avatar)
 {
     this.follow = follow;
     this.name   = name;
     this.type   = type;
     this.email  = email;
     this.avatar = avatar;
 }
示例#2
0
        //关注
        static public void Insert(Follow follow)
        {
            //string sql = "insert into favorite VALUES (" + favorite.user_id + "," + favorite.weike_id + ",'" + favorite.date + "',"+ favorite.isread+ ")";
            string          sql  = "insert into follow VALUES (" + follow.user_id + "," + follow.following_id + ",'" + follow.followDate + "')";
            MySqlConnection conn = Connection.getMySqlCon();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();
            sql             = "update user set followNum = followNum+1 where user_id = @user_id";
            cmd.CommandText = sql;
            cmd.Parameters.AddWithValue("@user_id", follow.user_id);
            cmd.ExecuteNonQuery();
            conn.Close();
        }
示例#3
0
        //找所有粉丝
        static public List <FollowData> FindAllFollowers(int user_id)
        {
            List <FollowData> fdList = new List <FollowData>();
            string            sql    = "SELECT follow.user_id,follow.following_id,follow.followDate,user.name,user.email,user.avatar FROM user inner join follow where user.user_id = follow.user_id and follow.following_id = @userid;";
            MySqlConnection   conn   = Connection.getMySqlCon();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = sql;
            cmd.Parameters.AddWithValue("@userid", user_id);
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Follow     follow = new Follow((int)reader["user_id"], (int)reader["following_id"], (DateTime)reader["followDate"]);
                FollowData fd     = new FollowData(follow, (string)reader["name"], "follower", reader.GetString("email"), reader.GetString("avatar"));
                fdList.Add(fd);
            }
            reader.Close();
            conn.Close();
            return(fdList);
        }