Get number of rows in SQL-Server with PHP

前端 未结 2 355
轮回少年
轮回少年 2021-01-21 12:43

I am fairly new to SQL-Server and PHP, but I\'m trying to get the total number of rows in my table with PHP.

This is the code I am using, it connects just fine, however

相关标签:
2条回答
  • 2021-01-21 13:00

    I believe that your call to

    print_r(sqlsrv_fetch_object($stmt));
    

    might be wrong. At least looking at the documentation in regards to how the call is made, indicates that there might be an error there.

    http://www.php.net/manual/en/function.sqlsrv-fetch-object.php

    You might want to try using fetch instead of fetch-object. I would suggest following the example.

    http://www.php.net/manual/en/function.sqlsrv-fetch.php

    0 讨论(0)
  • 2021-01-21 13:07

    Check it:

    http://www.php.net/manual/es/function.sqlsrv-num-rows.php

    "sqlsrv_num_rows() — Retrieves the number of rows in a result set"

    Like:

    $row_count = sqlsrv_num_rows( $stmt);
    echo 'numRows: ',$row_count;
    
    0 讨论(0)
提交回复
热议问题