|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-14 16:34 UTC] wez@php.net
[2005-02-15 06:52 UTC] jlim at natsoft dot com
[2005-02-16 00:24 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 12:00:02 2025 UTC |
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) }