请帮忙。我有以下代码:
$this->db->query("INSERT INTO " . DB_PREFIX . "competition_winners SET email_id= '" . $this->db->escape($data['email']) . "', name= '" . $this->db->escape($data['name']) . "', competition_id='" . (int)$data['competition_id'] . "'");
$rate = $this->db->query("SELECT competition_rate FROM " . DB_PREFIX . "customer WHERE email = '" . $data['email'] . "'");
$frate = $rate->row['competition_rate'];
$ratefinal=$frate+1;
$ratefinal=$frate+1;
$sql2 = "UPDATE" . DB_PREFIX . "customer SET competition_rate = '" . (int)$ratefinal . "' WHERE email= '" .$data['email'] . "'";
$query2 = $this->db->query($sql2);
}
查询不会更新任何内容。我无法获得vardump因为我正在使用Opencart CMS并且目前正在使用模型。我错过了什么?
答案 0 :(得分:1)
我认为你缺少tablename和update关键字之间的空格:
而不是:
$sql2 = "UPDATE" . DB_PREFIX . "customer SET competition_rate = '" . (int)$ratefinal . "' WHERE email= '" .$data['email'] . "'";
尝试
$sql2 = "UPDATE " . DB_PREFIX . "customer SET competition_rate = '" . (int)$ratefinal . "' WHERE email= '" .$data['email'] . "'";