Jump to content

Collecting userids and inserting row for them


EchoFool

Recommended Posts

Hey,

 

 

Im busy making a social network style wall feed for my site where people make a status and people can comment.

 

 

Now when some one comments the users active in the comment wall + original status maker gets notified but now the issue is theres so many while loops going on im thinking there must be a better way?

 

 

My current method is as follows:

 

1) Get the userid of the person who made the status

2) Collect all unique userid's of all the people who made a comment

3) Create the array of userids

4) Loop the array and insert row after row of each userid to notify them a comment was made on a feed they are active on.

 

 

Thing is - im thinking when i scale it up with alot of users this looping is going to increase the load alot so is there really any more efficient method i can use ?

Link to comment
Share on other sites

I would do it like this:

 

1. each status phrase has an id (statusID). Statuses are stored in table1

2. each comment has a time/date and the statusID they refer to, stored in table2

 

when you show a status, you also retrieve the statusID, then you go into table2 and retrieve all comments that have the same statusID, order them by datedesc,time desc.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.