Menu

here is the function sqlite3_num_rows

Help
2007-01-26
2013-04-22
  • Dennis Kaplan

    Dennis Kaplan - 2007-01-26

    Drop in and test following:

    !!! replace database and table name !!!

    <?php
    $db = sqlite3_open("yourSQLite.db")
    $query = "SELECT * FROM YourTable";
    $dbRes = sqlite3_query($db, $query);

    function sqlite3_num_rows($dbRes)
    {
        $n = 0;
        while(sqlite3_fetch_array($dbRes) != '')
        {
            $n = $n + 1;
        }
        return $n;
    }
    echo "Number of rows: " . sqlite3_num_rows($dbRes). "<br>";
    ?>

     
    • bfleisch

      bfleisch - 2007-04-05

      Hi Dennis,

      Why don't you use PHP built-in function sizeof() ?

      Ex:

      $my_array = sqlite3_num_rows($dbRes);

      echo "Number of rows: " . sizeof ($my_array);

      Bruno

       
  • Anonymous

    Anonymous - 2011-10-07

    because it returns number of cells, not rows. and it's never 0 even of table is empty it's 1.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.