Monday 11 October 2004 4:37:18 am
This must be implemented on a low level, probably in index.php, because articles are usually cached. You could make an SQL table with two columns, user id and object id, and whenever someone views an object you can detect this in index.php and store the information in the table. When you need the information, run some queries like this:
X is the object id of the object in question. First, fetch all users who has viewed this object:
select user_id from user_object_read_table where object_id = X;
For each user, fetch his object ids:
select object_id from user_object_read_table where user_id = 42;
Then you have a list of all objects this users has viewed. Do this for all the users, concatenate the results, and return the object ids that are most common. This will be somewhat slow on a medium to large site, so you might want to do it in a daily cronjob.
|