[PHP x SQLite3]PHPでSQLite3 #5データ更新(UPDATE)

PHPでSQLite3 #5データ更新(UPDATE)

$sql="SELECT id,cnt FROM $tableName WHERE id='{$id}'";
$result=$db->query($sql);
$row = $result->fetchArray();
$id=$row['id'];
$cnt=$row['cnt']+1;

$sql="UPDATE $tableName SET cnt = $cnt WHERE id = $id";
$result=$db->query($sql);