且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

相当于mysql_num_rows或mssql_num_rows的PDO

更新时间:2023-02-26 12:05:12

如果要计算行数,可以使用PDO做到这一点:

If you want to count the rows you can do this with PDO:

$sql = 'select * from users';
$data = $conn->query($sql);
$rows = $data->fetchAll();
$num_rows = count($rows);

在PDO中使用SELECT语句时,无法直接对行进行计数.

There is no way to directly count rows when using a SELECT statement with PDO.