|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49303 SQLite3::numRows() not implemented
Submitted: 2009-08-20 06:57 UTC Modified: 2009-08-21 01:55 UTC
From: rene at 809estudio dot com Assigned:
Status: Not a bug Package: SQLite related
PHP Version: 5.3.0 OS: Windows Vista Home Premium
Private report: No CVE-ID: None
 [2009-08-20 06:57 UTC] rene at 809estudio dot com
PHP's SQLite library possesed a function called sqlite_num_rows($result) which would return the number of rows present in a result from a query. This method is not implemented in the SQLiteResult class even if the documentation hints that it exists.

This is a core function which should not be overlooked.

Reproduce code:
   $db = new SQLite3('databaseName');

   $result = $db->query('SELECT * FROM tableName');

   echo "Number of rows : ".$result->numRows();

Expected result:
Number of rows: 100

Actual result:
Fatal error: Call to undefined method SQLite3Result::numRows() in {file} on line {line}


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-20 09:40 UTC]
SQLite and SQLite3 have different APIs.

SQLite3 doesn't implement buffered results so the total number of results isn't available. This is down to the fact that libsqlite really doesn't implement it either and its emulated by the old SQLite extension.
 [2009-08-21 01:55 UTC] rene at 809estudio dot com
Ok, I understand the situation, but still, the method is specified in the PHP documentation and there's even an example in a object oriented fashion (which I'm sure doesn't even work).

This method should be implemented regardless even as a hack since:

* SQLite1 library supported it. Not implementing it represents a drawback.
* Every major database library in PHP has a similar function. (SQLite1, MySQL, MSSQL, PostgreSQL)

Until now I have relied using a COUNT(*) or fetching all the arrays, storing them and counting them but I don't like neither of these methods.
 [2012-06-16 16:33 UTC] gudjonj at gmail dot com
I am having trouble with this as well.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 12 22:01:30 2024 UTC