MySQLi - Affected Rows
语法
mysqli_affected_rows(connection);
定义和用法
它用于获取有关先前 MySQL 操作中受影响的行数的信息。
示例
试试下面的例子 −
<?php $servername = "localhost:3306"; $username = "root"; $password = ""; $dbname = "TUTORIALS"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo"Database connected "; $sql = "SELECT * FROM Tutorials_auto"; mysqli_query($conn,$sql); echo "Affected rows: " . mysqli_affected_rows($conn); $conn->close(); ?>
上述代码的示例输出应该是这样的 −
Database connected Affected rows: 2