Add 1 to a field

前端 未结 7 1607
醉梦人生
醉梦人生 2021-02-06 23:58

How do I turn the following 2 queries into 1 query

$sql    = \"SELECT level FROM skills WHERE id = $id LIMIT 1;\";
$result = $db->sql_query($sql);
$level  = (         


        
7条回答
  •  情歌与酒
    2021-02-07 00:20

    With PDO and prepared query:

    $query = $db->prepare("UPDATE skills SET level = level + 1 WHERE id = :id")
    $query->bindValue(":id", $id);
    $result = $query->execute();
    

提交回复
热议问题