I would like to find the users who liked my products and the users who are following me. However, there might be users that who liked my products and also followed me, which then I will retrieve the same user id for two times. is there anyway to only record the same user id once instead of two times?
Below are the codes that I used to identify the users who liked my products and the users who followed me.
$userid = $productModel->userId;
$followCriteria = new CDbCriteria;
$followCriteria->addCondition("follow_userId = $userid");
$followers = Followers::model()->findAll($followCriteria);
foreach ($followers as $follower) {
$followuserid = $follower->userId;
$productid = $productModel->productId;
$favoriteCriteria = new CDbCriteria;
$favoriteCriteria->addCondition("productId = $productid");
$favoritee = Favorites::model()->findAll($favoriteCriteria);
foreach ($favoritee as $favoriteer) {
$favoriteuserid = $favoriteer->userId;