#31968 [Opn->Asn]: PDO getcolumnmeta returns no value when select returns not data
| From: | wez@php.net | Date: | Mon, 14 Feb 2005 15:34:24 +0000 |
| Subject: | #31968 [Opn->Asn]: PDO getcolumnmeta returns no value when select returns not data | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-74021@lists.php.net to get a copy of this message | ||
ID: 31968
Updated by: wez@php.net
Reported By: jlim at natsoft dot com
-Status: Open
+Status: Assigned
Bug Type: *Database Functions
Operating System: WinXP SP2
PHP Version: 5CVS-2005-02-14 (dev)
-Assigned To:
+Assigned To: wez
New Comment:
I'll look into it.
PS: John, can you submit PDO bugs via PECL instead in the future. I'd
love to find out more about the OCI problems you mentioned.
http://pecl.php.net/bugs/report.php?package=PDO
http://pecl.php.net/bugs/report.php?package=PDO_OCI
etc.
thanks!
Previous Comments:
------------------------------------------------------------------------
[2005-02-14 12:09:33] jlim at natsoft dot com
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 this bug report at http://bugs.php.net/?id=31968&edit=1