php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31968 PDO getcolumnmeta returns no value when select returns not data
Submitted: 2005-02-14 12:09 UTC Modified: 2005-09-20 21:57 UTC
From: jlim at natsoft dot com Assigned: wez (profile)
Status: Not a bug Package: PDO related
PHP Version: 5CVS-2005-02-14 (dev) OS: WinXP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
32 + 28 = ?
Subscribe to this entry?

 
 [2005-02-14 12:09 UTC] 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) }


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-14 16:34 UTC] wez@php.net
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!
 [2005-02-15 06:52 UTC] jlim at natsoft dot com
Hi

This is probably a problem with sqlite. I just tested with pdo's pgsql extension and getcolumnmeta worked fine under both cases.

John
 [2005-02-16 00:24 UTC] sniper@php.net
Report to PECL. This is not PECL bug system..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC