*/
class SemanticScuttle_Service_Vote extends SemanticScuttle_DbService
{
-
-
-
/**
* Returns the single service instance
*
$row = $this->db->sql_fetchrow($dbres);
$this->db->sql_freeresult($dbres);
- if (!$row) {
- return false;
- }
-
return (int)$row['sum'];
}//public function getVoting(..)
*/
public function getVotes($bookmark)
{
- $query = 'SELECT COUNT(vote) as count FROM ' . $this->getTableName()
+ $query = 'SELECT COUNT(vote) as count FROM '
+ . $this->getTableName()
. ' WHERE bid = "' . $this->db->sql_escape($bookmark) . '"';
if (!($dbres = $this->db->sql_query_limit($query, 1, 0))) {
$row = $this->db->sql_fetchrow($dbres);
$this->db->sql_freeresult($dbres);
- if (!$row) {
- return false;
- }
-
return (int)$row['count'];
}
*/
public function hasVoted($bookmark, $user)
{
- $query = 'SELECT COUNT(vote) as count FROM ' . $this->getTableName()
+ $query = 'SELECT COUNT(vote) as count FROM '
+ . $this->getTableName()
. ' WHERE'
. ' bid = "' . $this->db->sql_escape($bookmark) . '"'
. ' AND uid = "' . $this->db->sql_escape($user) . '"';
$row = $this->db->sql_fetchrow($dbres);
$this->db->sql_freeresult($dbres);
- if (!$row) {
- return null;
- }
-
return (int)$row['count'] == 1;
}