$stmt = $pdo->prepare("UPDATE users SET name = ? WHERE id = ?"); $stmt->execute([$name, $id]); $rowCount = $stmt->rowCount(); echo "Updated $rowCount rows";
$stmt = $pdo->prepare("SELECT * FROM users WHERE age > ?"); $stmt->execute([$age]); $rowCount = $stmt->rowCount(); echo "Found $rowCount users";This example prepares and executes a SELECT query to retrieve all users with an age greater than a certain value. The rowCount method is used to get the number of rows returned by the query. Package Library: PHP Data Objects (PDO) is a package library that provides a consistent interface for accessing different databases in PHP. The PDOStatement rowCount method is a part of this package and can be used with any supported database driver.