php.net |  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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gustavolopez at cantv dot net
New email:
PHP Version: OS:

 

 [2008-03-29 22:49 UTC] gustavolopez at cantv dot net
Description:
------------
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 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-30 10:17 UTC] scottmac@php.net
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
<?php
 $db = new SQLite3(':memory:');
 $a = 'CREATE TABLE test (Cedula varchar(12) PRIMARY KEY ON CONFLICT ROLLBACK NOT NULL COLLATE NOCASE, ';
 $a .= 'Nombres varchar(50) NOT NULL COLLATE NOCASE, Apellidos  varchar(50) COLLATE NOCASE, Edad integer DEFAULT 0) ';
 echo "create Table test<br>";
 $db->exec($a);
 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)){
	var_dump($result);
 }
 echo "<br><br>Total Columns (expected 4): ".$results->numColumns();
 $results->finalize();
 $db->Close();
?>
 [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:
RETURN_LONG(sqlite3_data_count(*(internp->intern_stmt)));
to:
RETURN_LONG(sqlite3_column_count(*(internp->intern_stmt)));
 [2008-04-09 19:45 UTC] scottmac@php.net
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 pecl.php.net.

In case this was a pecl.php.net 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: Sun Dec 22 05:01:30 2024 UTC