Skip to content

Commit 7414c20

Browse files
update com pdo
1 parent 94b1c2d commit 7414c20

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

update-stmt.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
include './connection.php';
4+
5+
$conn = getConnection();
6+
7+
$sql = 'UPDATE produto SET descricao = :desc, qtd = :qtd, valor = :valor WHERE id = :id';
8+
9+
$descricao = 'Feijão 1';
10+
$qtd = 11;
11+
$valor = 11.80;
12+
$id = 2;
13+
14+
$stmt = $conn->prepare($sql);
15+
$stmt->bindParam(':desc', $descricao);
16+
$stmt->bindParam(':qtd', $qtd);
17+
$stmt->bindParam(':valor', $valor);
18+
$stmt->bindParam(':id', $id);
19+
20+
if($stmt->execute()){
21+
echo 'Atualizado com sucesso!';
22+
}else{
23+
echo 'Erro ao atualizar!';
24+
}

0 commit comments

Comments
 (0)