示例#1
0
 /**
  * get_voters
  * This returns the users that voted for the specified object
  * This is an array of user ids
  */
 public function get_voters($object_id)
 {
     if (parent::is_cached('democratic_voters', $object_id)) {
         return parent::get_from_cache('democratic_voters', $object_id);
     }
     $sql = "SELECT `user` FROM `user_vote` WHERE `object_id` = ?";
     $db_results = Dba::read($sql, array($object_id));
     $voters = array();
     while ($results = Dba::fetch_assoc($db_results)) {
         $voters[] = $results['user'];
     }
     parent::add_to_cache('democratic_vote', $object_id, $voters);
     return $voters;
 }
示例#2
0
 /**
  * get_vote
  * This returns the current count for a specific song
  */
 public function get_vote($id)
 {
     if (parent::is_cached('democratic_vote', $id)) {
         return parent::get_from_cache('democratic_vote', $id);
     }
     $sql = 'SELECT COUNT(`user`) AS `count` FROM `user_vote` ' . "WHERE `object_id`='" . Dba::escape($id) . "'";
     $db_results = Dba::read($sql);
     $results = Dba::fetch_assoc($db_results);
     parent::add_to_cache('democratic_vote', $id, $results['count']);
     return $results['count'];
 }