Count number of rows buffered in sqlite result set

后端 未结 4 1522
说谎
说谎 2020-12-22 04:58

I am using count function to get the number of rows buffered in a resultset.

But it always returns count as one even if resultset is empty.

Please see the co

4条回答
  •  攒了一身酷
    2020-12-22 05:18

    As per your comment if you just want to return the count of records you could wrap your query in a SELECT COUNT(*) and change $dbhandle->query to $dbhandle->querySingle. This will work with or without LIMIT.

    $dbhandle = new SQLite3("sqlitedb_111.db");
    $selQuery1 = "SELECT COUNT(*) FROM (SELECT id,dbname,tabname,fieldname FROM scan_results ORDER BY id ASC LIMIT  0,10)";
    $resQuery1 = $dbhandle->querySingle($selQuery1);
    print count($resQuery1);
    

提交回复
热议问题