+2

Followers I'm web

I need to make a web to have a button were you press it and you start following the user. But I didn't on a very inefficient way. The system gets your username and a column from the database and stores your username in the others column with a space between usernames. When you have to count followers, it gets all the string with the names and with an explode function I separe all the usernames and I insert them into an array. But the varchar column has 65535 characters as maximum. So when it gets to 20 k followers, it will get an error because the limit is reached. But I couldn't think another way of making it. I'm thinking of doing that but in a file with the username. Is there a better way of doing it?

4/4/2020 2:38:57 PM

Rafael Bradley

2 Answers

New Answer

+1

Don't know nothing about your table layout or structure; so I don't know if this was even feasible. Create a table that contains two columns, e.g. 'user_id' and 'follower_id'. Both IDs saved in this table should strictly reference to user ID in users table, meaning you should not allow insertion or modification by arbitrary value here. Suppose you have a user with ID 1; when someone follows user with ID 1 - you create new record with value 1 for 'user_id' column and the follower's user ID for 'follower_id'. Example (in table) user_id folllower_id 1 2 1 3 ... Here means user with ID 1 is followed by 2 users, those are users with ID 2 and 3. * This table can also be used to record users that are being followed.

0

pubg