class Mongodb_VoteStorage in Voting API 7.3
Same name and namespace in other branches
- 8.3 votingapi.api.php \Mongodb_VoteStorage
Hierarchy
- class \Mongodb_VoteStorage
Expanded class hierarchy of Mongodb_VoteStorage
1 string reference to 'Mongodb_VoteStorage'
- votingapi.api.php in ./
votingapi.api.php - Provides hook documentation for the VotingAPI module.
File
- ./
votingapi.api.php, line 128 - Provides hook documentation for the VotingAPI module.
View source
class Mongodb_VoteStorage {
/**
* Save a vote in the database.
*
* @param $vote instance of VotingApi_Vote.
*/
function addVote(&$vote) {
mongodb_collection('votingapi_vote')
->insert($vote);
}
/**
* Delete votes from the database.
*
* @param $votes An array of VotingApi_Vote instances to delete.
* Minimally, each vote must have the 'vote_id' key set.
* @param $vids
* A list of the 'vote_id' values from $votes.
*/
function deleteVotes($votes, $vids) {
mongodb_collection('votingapi_vote')
->delete(array(
'vote_id' => array(
'$in' => array_map('intval', $vids),
),
));
}
/**
* Select individual votes from the database.
*
* @param $criteria instance of VotingApi_Criteria.
* @param $limit
* An integer specifying the maximum number of votes to return. 0 means
* unlimited and is the default.
* @return
* An array of VotingApi_Vote objects matching the criteria.
*/
function selectVotes($criteria, $limit) {
$find = array();
foreach ($criteria as $key => $value) {
$find[$key] = is_array($value) ? array(
'$in' => $value,
) : $value;
}
$cursor = mongodb_collection('votingapi_vote')
->find($find);
if (!empty($limit)) {
$cursor
->limit($limit);
}
$votes = array();
foreach ($cursor as $vote) {
$votes[] = $vote;
}
return $votes;
}
/**
* TODO
*
*/
function standardResults($entity_id, $entity) {
// TODO
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Mongodb_VoteStorage:: |
function | Save a vote in the database. | ||
Mongodb_VoteStorage:: |
function | Delete votes from the database. | ||
Mongodb_VoteStorage:: |
function | Select individual votes from the database. | ||
Mongodb_VoteStorage:: |
function | TODO |