Row count with PDO

前端 未结 23 3212
春和景丽
春和景丽 2020-11-21 22:57

There are many conflicting statements around. What is the best way to get the row count using PDO in PHP? Before using PDO, I just simply used mysql_num_rows.

23条回答
  •  别那么骄傲
    2020-11-21 23:32

    A quick one liner to get the first entry returned. This is nice for very basic queries.

    query("select count(*) from table")->fetch());
    ?>
    

    Reference

提交回复
热议问题