Php mysql-更新值是当前值加上新值

Php mysql-更新值是当前值加上新值,php,mysql,pdo,sql-update,Php,Mysql,Pdo,Sql Update,我有以下更新查询快照限制需要是其在数据库中的当前值加上我的新值$add\u shots。使用绑定时有什么方法可以做到这一点吗 //figure out how many screenshots to add $add_shots = $_POST['Quantity'] * 500; $stmt = $db->prepare(" UPDATE accounts SET orders = :orders, shots_limit = :shots_limi

我有以下更新查询<代码>快照限制需要是其在数据库中的当前值加上我的新值
$add\u shots
。使用绑定时有什么方法可以做到这一点吗

//figure out how many screenshots to add
$add_shots = $_POST['Quantity'] * 500;

$stmt = $db->prepare("
    UPDATE accounts 
    SET orders = :orders,
        shots_limit = :shots_limit
    WHERE account_id = :account_id  
");

//bindings
$binding = array(
    'orders' => $orders_str,
    'shots_limit' => $add_shots + ORIGINAL VALUE
    'account_id' => $result['account_id']
);

$status = $stmt->execute($binding);

我想这就是你要找的。只需在更新中使用当前值

$stmt = $db->prepare("
    UPDATE accounts 
    SET orders = :orders,
        shots_limit = shots_limit + :shots_limit
    WHERE account_id = :account_id  
");

//bindings
$binding = array(
    'orders' => $orders_str,
    'shots_limit' => $add_shots,
    'account_id' => $result['account_id']
);

那部分不是代码,它是用来解释我想在那里做什么的。你可以尝试做
shots\u limit=:shots\u limit+shots\u limit
,然后只绑定
:shots\u limit
,其中“shots\u limit”指的是原始值加上我的绑定值。。。有道理。我知道我以前在“常规”查询中做过,但在使用绑定时从未做过。我要试试这个。