From:             balustefan at gmail dot com
Operating system: FreeBSD 7.0-RELEASE i386
PHP version:      5.2.6
PHP Bug Type:     PDO related
Bug description:  columnCount() on sqlite3 returns invalid column count

Description:
------------
Seems like columnCount() returns invelid int value. No mater how many 
results match a query, columnCount() will return int(3). Even for no 
results.
The underlying database is sqlite3-3.5.6

Reproduce code:
---------------
1. create an sql table in a freshly database file:

sqlite> create table hosts(hw char(18),
> ip varchar(16),
> extra text,
> constraint hw_pkey primary key(hw));

2. insert some data into it:

sqlite> insert into hosts
values('00:19:21:57:44:f8','89.122.239.55','comment');

sqlite> insert into hosts
values('00:e0:4c:20:dc:15','194.102.255.234','some comment');

3. use a php function like this one to fetch a "host":

function fetchHost($hwAddr)
{
        $sqlQuery = "SELECT * FROM hosts WHERE hw = ?";

        if (($sqlStatement = $sqlPDO->prepare($sqlQuery)) === false)
                return (bool) false;

        if ($sqlStatement->execute(array($hwAddr)) === false)
                return (bool) false;

        var_dump($sqlStatement->columnCount());

        if ($sqlStatement->columnCount() < 1)
                return (bool) true;

        return $sqlStatement->fetch(PDO::FETCH_ASSOC);
}



Expected result:
----------------
The output of var_dump() should be 0 if no rows are found, and number of 
rows if all is ok.

Actual result:
--------------
On 0 or more rows returned, columnCount() returns int(3).

-- 
Edit bug report at http://bugs.php.net/?id=46429&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46429&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46429&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46429&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46429&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46429&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46429&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46429&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46429&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46429&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46429&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46429&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46429&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46429&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46429&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46429&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46429&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46429&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46429&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46429&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46429&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46429&r=mysqlcfg

Reply via email to