我将创建一个自定义表,存储a)进行评级的用户b)被评级的用户c)评级d)评级时间。在这四种方法之间,您应该能够以很少的开销或PHP处理来存储、聚合和有效地查询数据。
更新
note: this is pseudocode
function get_user_rating( $user_id ) {
$rating = get_from_database(
\'SELECT AVG(rating)
FROM ratings_table
WHERE user_being_rated = \'.$user_id
);
return $rating;
}
function add_user_rating( $rater, $rated, $rating ) {
//check to see if there is already a rating to avoid duplicate records
if( already_rated( $rater, $rated ) ) {
//remove previous rating
remove_rating( $rater, $rated );
}
//insert current rating
insert_into_database(
\'INSERT INTO ratings_table
( user_doing_rating, user_being_rated, rating, time ) VALUE
( \'.$rater.\', \'.$rated.\', \'.$rating.\', CURTIME() )\'
);
}