When operating databases using PHP, PDO is a recommended way to provide a unified, flexible and secure interface. Among them, the PDOStatement::rowCount() method is often used to obtain the number of rows affected by SQL operations, but it behaves slightly differently in different statement types (such as SELECT, INSERT, UPDATE, DELETE). This article focuses on how to avoid common misunderstandings.
PDOStatement::rowCount