HTML and CSS Reference
In-Depth Information
return array(
'room_id' => $room_id,
'question_id' => $question_id,
);
}
}
The database query increments the vote count by 1 for the question with the given ID by adding 1 to its current
value— vote_count = vote_count+1 —and then returns the room and question IDs.
Marking a Question as Answered
Finally, to mark a question as answered, the is_answered column for the question with the given ID is updated to 1 .
Add the following bold code to Question_Model :
$stmt->closeCursor();
return array(
'room_id' => $room_id,
'question_id' => $question_id,
);
}
/**
* Marks a given question as answered
*
* @param $room_id int The ID of the room
* @param $question_id int The ID of the question
* @return array The IDs of the room and question
*/
public function answer_question( $room_id, $question_id )
{
$sql = "UPDATE questions
SET is_answered = 1
WHERE id = :question_id";
$stmt = self::$db->prepare($sql);
$stmt->bindParam(':question_id', $question_id, PDO::PARAM_INT);
$stmt->execute();
$stmt->closeCursor();
return array(
'room_id' => $room_id,
'question_id' => $question_id,
);
}
}
 
Search WWH ::




Custom Search