$sql = "INSERT INTO users (name, email) VALUES ('John Doe', 'johndoe@example.com')"; $affectedRows = $pdo->exec($sql);
$sql = "UPDATE users SET name = 'Jane Doe' WHERE email = 'janedoe@example.com'"; $affectedRows = $pdo->exec($sql);This example updates the name of the user with the email "janedoe@example.com" to "Jane Doe" and stores the number of affected rows in the $affectedRows variable. The PDO::exec() method belongs to the PHP PDO (PHP Data Objects) package library, which is a unified database API that allows developers to work with various databases using a consistent interface.