- Timestamp:
- 2006/12/12 23:43:18 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
temp/test-xoops.ec-cube.net/html/modules/xoopspoll/class/xoopspolllog.php
r405 r770 45 45 $this->initVar("user_id", XOBJ_DTYPE_INT, 0); 46 46 $this->initVar("time", XOBJ_DTYPE_INT, null); 47 $this->initVar("rating_id", XOBJ_DTYPE_INT, null); 48 $this->initVar("comment", XOBJ_DTYPE_TXTAREA, null); 47 49 if ( !empty($id) ) { 48 50 if ( is_array($id) ) { … … 63 65 $$k = $v; 64 66 } 67 65 68 $log_id = $this->db->genId($this->db->prefix("xoopspoll_log")."_log_id_seq"); 66 $sql = "INSERT INTO ".$this->db->prefix("xoopspoll_log")." (log_id, poll_id, option_id, ip, user_id, time ) VALUES ($log_id, $poll_id, $option_id, ".$this->db->quoteString($ip).", $user_id, ".time().")";69 $sql = "INSERT INTO ".$this->db->prefix("xoopspoll_log")." (log_id, poll_id, option_id, ip, user_id, time, rating_id, comment) VALUES ($log_id, $poll_id, $option_id, ".$this->db->quoteString($ip).", $user_id, ".time().", $rating_id, ".$this->db->quoteString($comment).")"; 67 70 $result = $this->db->query($sql); 68 71 if (!$result) { … … 148 151 { 149 152 $db =& Database::getInstance(); 150 $sql = "SELECT DISTINCT user_id FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".intval($poll_id)." AND user_id > 0 ";153 $sql = "SELECT DISTINCT user_id FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".intval($poll_id)." AND user_id > 0 AND rating_id = 1"; 151 154 $users = $db->getRowsNum($db->query($sql)); 152 $sql = "SELECT DISTINCT ip FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".intval($poll_id)." AND user_id=0 ";155 $sql = "SELECT DISTINCT ip FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".intval($poll_id)." AND user_id=0 AND rating_id = 1"; 153 156 $anons = $db->getRowsNum($db->query($sql)); 154 157 return $users+$anons; … … 159 162 { 160 163 $db =& Database::getInstance(); 161 $sql = "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id = ".intval($poll_id) ;164 $sql = "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id = ".intval($poll_id)." AND rating_id = 1"; 162 165 list($votes) = $db->fetchRow($db->query($sql)); 163 166 return $votes; … … 165 168 166 169 // public static 167 function getTotalVotesByOptionId($option_id )170 function getTotalVotesByOptionId($option_id, $rating_id) 168 171 { 169 172 $db =& Database::getInstance(); 170 $sql = "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE option_id = ".intval($option_id) ;173 $sql = "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE option_id = ".intval($option_id)." AND rating_id = $rating_id"; 171 174 list($votes) = $db->fetchRow($db->query($sql)); 172 175 return $votes;
Note: See TracChangeset
for help on using the changeset viewer.
