我试图添加到表中的现有十进制值,我使用下面的sql:
UPDATE Funds SET Funds = Funds + :funds WHERE id = :id
我使用pdo类来处理我的db调用,使用下面的方法来更新db,但我无法弄清楚如何修改它以输出上述查询,任何想法?
public function add_to_values($table, $info, $where, $bind="") {
$fields = $this->filter($table, $info);
$fieldSize = sizeof($fields);
$sql = "UPDATE " . $table . " SET ";
for($f = 0; $f < $fieldSize; ++$f) {
if($f > 0)
$sql .= ", ";
$sql .= $fields[$f] . " = :update_" . $fields[$f];
}
$sql .= " WHERE " . $where . ";";
$bind = $this->cleanup($bind);
foreach($fields as $field)
$bind[":update_$field"] = $info[$field];
return $this->run($sql, $bind);
}