I am allowing users to vote on content, so I need to save a user input to my database, and then get a COUNT()
of the input to return back.
The voting works fine, but reading the results back always returns false. The only work aro开发者_StackOverflowund I have found is to rebuild the database connection a second time to count the votes. Is there any other way to do this?
Here is my code:
$vote = $conn->prepare($voteSQL);
$vote->execute(array(':postId'=>$voteId
, ':voterId'=>$userId
, ':voteType'=> $voteDir
,':voteType2'=> $voteDir
,':voteType3'=> $voteDir));
$tallyVotes = $conn->prepare($tallySQL);
$tallyVotes->execute(array(':postId'=>$voteId));
$updatedTally = $tallyVotes->fetch();
精彩评论