It is data table that store the users' rating data
CREATE TABLE `rates` (
`users_id` int(10) unsigned NOT NULL,
`flag` varchar(16) NOT NULL DEFAULT '',
`some_id` int(10) unsigned NOT NULL,
PRIMARY KEY `uid_flag_sid` (`users_id`, `flag`, `some_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
// example data
+----------+-------+---------+
| users_id | flag | some_id |
+----------+-------+---------+
| 1 | topic | 1 |
| 1 | reply | 1 |
+----------+-------+---------+
The sample data shows that a user with id=1 has given scores to the topic with id=1 and the reply with id=1
Then, how to insert a new record into this table and avoid the duplication? just $rate->save()
?