i have extracted a list of usernames using the answers from this:
now i have another issue. I have a friend table made up of just 2 columns, requestor and buddy both form a composite primary key.
Now suppose i have an array of facebook friends for a given user using the above SO question.
how do i automatically make them friends in my web app as well?
That means if i have 5 actual friends for a user called 'usera'. i need to perform 10 insert statements.
eg: friendA, usera and usera, friendA so that friendA is reflected as a friend for usera.
i understand that insert select is efficient. but unfortunately the list of usernames of these friends are obtained via a PHP array of values using IN clause as suggested by fellow SO members in my above question.
So what should i do?
should i
a) loop through the names and perform 2 insert statements for each step?
b) use insert select? but how to do it exactly?
my DB is designed this way:
1 table called users with usernames and fb_uid where the username is primary key and fb_uid is nullable.
1 table called friends with a column called requestor and another column called buddy. Both columns form a composite key.
A friendship is established between 2 people (usera, userb) in my web app when you have the following data: (usera, userb) and (userb, usera) in the friends table.
Thank you.