简体   繁体   中英

UPDATE and Increment column value POD

I'm trying to sum/add another value to the actual value in the database but this is not working. Any suggestions?

$suplies=15;
$user_id="100234";

$sql = "UPDATE table SET suplies=suplies+".$suplies." WHERE user_id=?";
$q = $conn->prepare($sql);
$q->execute(array(':suplies'=>$suplies,':user_id'=>$user_id));

完全使用命名的占位符即可。

$sql = "UPDATE table SET suplies = suplies + :suplies WHERE user_id = :user_id";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM