Get Number of Rows from a Select statement

前端 未结 2 1024
情歌与酒
情歌与酒 2021-01-02 00:45

I have this:

$dbh = new PDO(\"odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename\", $username, $password);

$sql = \"SELECT * FROM this_         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-02 01:06

    SELECT count(*) FROM this_table is an option...

    Regarding rowCount:

    PDOStatement::rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding PDOStatement object.

    If the last SQL statement executed by the associated PDOStatement was a SELECT statement, some databases may return the number of rows returned by that statement. **

    However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.

提交回复
热议问题