|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58129 numColumns() always returns zero (0)
Submitted: 2008-03-29 22:49 UTC Modified: 2008-04-09 19:45 UTC
From: gustavolopez at cantv dot net Assigned:
Status: Closed Package: sqlite3 (PECL)
PHP Version: 5.2.5 OS: Windows XP SP2
Private report: No CVE-ID: None
 [2008-03-29 22:49 UTC] gustavolopez at cantv dot net
I create a SQLIte3 DB with 1 table, 4 fields (varchar (20))

I inserted 3 records in it.

I connect to DB, select * from these table.

The function numColumns() always return zero (0), but the query returns 3 rows, 4 fields, as expected 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-30 10:17 UTC]
Can you show me a small reproduce script so I can properly test a fix.
 [2008-04-04 18:01 UTC] gustavolopez at cantv dot net
I'm testing this with a small SQLite3 class that I Wrote. How Can I submit the class ?
 [2008-04-04 18:32 UTC] gustavolopez at cantv dot net
 $db = new SQLite3(':memory:');
 $a .= 'Nombres varchar(50) NOT NULL COLLATE NOCASE, Apellidos  varchar(50) COLLATE NOCASE, Edad integer DEFAULT 0) ';
 echo "create Table test<br>";
 echo "INSERT 3 rows<br>";
 $db->exec("Insert INTO test (Cedula, Nombres, Apellidos, Edad) VALUES ('18888', 'MARIA', 'MENDIETA', 90) ");
 $db->exec("Insert INTO test (Cedula, Nombres, Apellidos, Edad) VALUES ('18222', 'MARIA', 'MENDIETA', 90) ");
 $db->exec("Insert INTO test (Cedula, Nombres, Apellidos, Edad) VALUES ('182223', 'MARIA', 'MENDIETA', 90) ");
 echo "<br>SELECT ALL rows<br>";
 $results = $db->query("SELECT * FROM test");
 while ($result = $results->fetchArray(SQLITE3_NUM)){
 echo "<br><br>Total Columns (expected 4): ".$results->numColumns();
 [2008-04-04 18:43 UTC] gustavolopez at cantv dot net
From SQLite3 API: "The sqlite3_column_count() function returns the number of columns in the results set. sqlite3_column_count() can be called at any time after sqlite3_prepare_v2(). sqlite3_data_count() works similarly to sqlite3_column_count() except that it only works following sqlite3_step(). If the previous call to sqlite3_step() returned SQLITE_DONE or an error code, then sqlite3_data_count() will return 0 whereas sqlite3_column_count() will continue to return the number of columns in the result set."

You must change line 1088 in SQLite3.c:
 [2008-04-09 19:45 UTC]
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

This will be fixed in the next release.

I've used sqlite3_column_count instead of sqlite3_data_count.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 10:01:27 2024 UTC