INSERT, UPDATE, DELETE

INSERT, UPDATE and DELETE modify data and go through prepared statements. rowCount() gives the number of rows affected, and lastInsertId() returns the id generated after an INSERT. An UPDATE or DELETE without WHERE acts on all rows.

Example

$stmt = $pdo->prepare('UPDATE produits SET prix = :p WHERE id = :id');
$stmt->execute(['p' => 9.9, 'id' => 4]);

Related concepts

The whole glossary