dpfad62426 2012-07-31 22:16
浏览 13
已采纳

如何从DBA函数中获取记录的总长度?

I just want to know if there are any funcitons that can find the total length of the records the DBA function fetch from the DB file. Thanks a lot!

  • 写回答

2条回答 默认 最新

  • ds11111111111111111 2012-07-31 22:27
    关注

    If you are using PDO, you can use get the number of rows via:

    <?php
    $qry = $dbh->prepare('select * FROM fruit');
    $del->execute();
    $count = $qry->rowCount();
    print("Found $count rows.
    ");
    ?>
    

    You can also get the number of rows is you are using mysqli like this:

    <?php
    // yada yada
    $result = $mysqli->query("SELECT Code, Name FROM Country ORDER BY Name");
    $row_cnt = $result->num_rows;
    printf("Result set has %d rows.
    ", $row_cnt);
    ?>
    

    Be aware that this one won't return the number of rows when your query is an insert, delete, update or replace. You would need to use the affected rows for that.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?