Example #1
0
 public function statusSelection($ids, $action)
 {
     $rating_fields = array("one_star", "two_star", "three_star", "four_star", "five_star");
     parent::statusSelection($ids, $action);
     $result = Db::getInstance()->getAll('SELECT * FROM ' . DB_PREFIX . 'feedback WHERE id_feedback IN(' . pSQL(implode(',', $ids)) . ')');
     foreach ($result as $row) {
         $field = pSQL($rating_fields[$row["rating"] - 1]);
         if ($this->feedbackStateExists($row['id_product'])) {
             Db::getInstance()->exec('UPDATE ' . DB_PREFIX . 'feedback_state SET times=times+1,total_rating=total_rating+' . (int) $row["rating"] . ",`" . $field . "`=`" . $field . "`+1\n\t\t\t\tWHERE id_product=" . intval($row['id_product']));
         } else {
             Db::getInstance()->exec('INSERT INTO ' . DB_PREFIX . 'feedback_state SET id_product=' . intval($row['id_product']) . ',times=1,total_rating=' . (int) $row["rating"] . ",`" . $field . "`=`" . $field . "`+1");
         }
     }
     return true;
 }