Hi guys, I’m creating a website where you can vote on different games, and they will then get a rank according to the votes. I want my voting system to recognize wether a vote on a certain platform for the game was posted by this user before, and if so he/she should be able to update this vote. If he/she hasn’t voted yet, the person should be able to submit a new vote.
I already have the system recognizing wether a vote exists or not, but no matter what a new vote would be submitted instead of an already submitted vote updated. How can i fix this?
Here is my code in the controller:
protected function getRankingList($model)
$rankings = array();
foreach($tab_list as $key=>$value)
if(Ranking::model()->find("create_user_id=$user_id and game_id=$game_id and platform_id=$key"))
$rank=Ranking::model()->find("create_user_id=$user_id and game_id=$game_id and platform_id=$key");
$rank = new Ranking;
$valid = $rank->validate();
Please let me know if something is not explained well enough - I’m not a native english speaker