From: jlim at natsoft dot com
Operating system: WinXP SP2
PHP version: 5CVS-2005-02-14 (dev)
PHP Bug Type: *Database Functions
Bug description: PDO getcolumnmeta returns no value when select returns not
data
Description:
------------
Hi,
I think PDO should return the getColumnMeta info even if no data is
returned, so long as SQL parses correctly and table exists. I believe that
all of the non-PDO database extensions work like this.
I don't know whether this is an SQLite issue or PDO issue.
Thanks, John Lim
Reproduce code:
---------------
<?php
function GetColumnMeta($db)
{
$st2 = $db->prepare("select * from hash ");
$ok = $st2->execute();
echo "<h3>GetColumnMeta</h3>";
for ($i=0; $i<2; $i++) {
$col = $st2->getColumnMeta($i);
var_dump($col);echo "<br>";
}
}
$db = new PDO('sqlite:' . getenv('HOME') . "/.web-watch.sql3");
$db->query('create table hash(url primary key, hash)');
$db->query('delete from hash');
GetColumnMeta($db);
$db->query("insert into hash (url, hash) values
('http://yahoo.com/','100')");
GetColumnMeta($db);
?>
Expected result:
----------------
GetColumnMeta
array(6) { ["native_type"]=> string(6) "string" ["flags"]=> array(0) { }
["name"]=> string(3) "url" ["len"]=> int(-1) ["precision"]=> int(0)
["pdo_type"]=> int(2) }
array(6) { ["native_type"]=> string(6) "string" ["flags"]=> array(0) { }
["name"]=> string(4) "hash" ["len"]=> int(-1) ["precision"]=> int(0)
["pdo_type"]=> int(2) }
GetColumnMeta
array(6) { ["native_type"]=> string(6) "string" ["flags"]=> array(0) { }
["name"]=> string(3) "url" ["len"]=> int(-1) ["precision"]=> int(0)
["pdo_type"]=> int(2) }
array(6) { ["native_type"]=> string(6) "string" ["flags"]=> array(0) { }
["name"]=> string(4) "hash" ["len"]=> int(-1) ["precision"]=> int(0)
["pdo_type"]=> int(2) }
Actual result:
--------------
GetColumnMeta
bool(false)
bool(false)
GetColumnMeta
array(6) { ["native_type"]=> string(6) "string" ["flags"]=> array(0) { }
["name"]=> string(3) "url" ["len"]=> int(-1) ["precision"]=> int(0)
["pdo_type"]=> int(2) }
array(6) { ["native_type"]=> string(6) "string" ["flags"]=> array(0) { }
["name"]=> string(4) "hash" ["len"]=> int(-1) ["precision"]=> int(0)
["pdo_type"]=> int(2) }
--
Edit bug report at http://bugs.php.net/?id=31968&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31968&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=31968&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=31968&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31968&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31968&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31968&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31968&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31968&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31968&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31968&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=31968&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=31968&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31968&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31968&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31968&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31968&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31968&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31968&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31968&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31968&r=mysqlcfg