php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57001 PDOStatement::getColumnMeta dies
Submitted: 2006-05-04 17:10 UTC Modified: 2013-02-18 00:35 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: cfilin at intermedia dot net Assigned:
Status: No Feedback Package: PDO (PECL)
PHP Version: 5.1.2 OS: Linux Fedora Core 3
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
41 - 6 = ?
Subscribe to this entry?

 
 [2006-05-04 17:10 UTC] cfilin at intermedia dot net
Description:
------------
Greetings

I obtained PDO together with PHP 5.1.2.

Here's my PHP info:

phpinfo()
PHP Version => 5.1.2

System => Linux cflinux.intermedia.net 2.6.10-1.771_FC2 #1 Mon Mar 28 00:50:14 EST 2005 i686
Build Date => Apr 13 2006 01:09:45
Configure Command =>  './configure' '--with-zlib' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-openssl' '--with-curl' '--enable-ftp' '-
-enable-pdo=shared' '--with-pdo-pgsql=shared,/usr/local/pgsql/bin/pg_config' '--with-pgsql=shared,/usr/local/pgsql/bin/pg_config' '--with-mm'
 '--enable-shmop' '--enable-sysvsem' '--enable-sockets' '--enable-parsekit' '--without-msql' '--without-mysql' '--without-unixODBC' '--withou
t-pdo-sqlite' '--without-sqlite' '--without-sybase'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/lib/php.ini
PHP API => 20041225
PHP Extension => 20050922
Zend Extension => 220051025
Debug Build => no
Thread Safety => disabled
Zend Memory Manager => enabled
IPv6 Support => enabled
Registered PHP Streams => php, file, http, ftp, compress.zlib, https, ftps
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters => string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, convert.iconv.*, zlib.*


Here's list of modules:

[PHP Modules]
ctype
curl
date
dom
ftp
hash
iconv
libxml
openssl
parsekit
pcre
PDO
pdo_pgsql
pgsql
posix
Reflection
runkit
session
shmop
SimpleXML
sockets
SPL
standard
sysvsem
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

I am using PDO to connect to Postgres database. When I am doung a query that returns an empty record set (For example 
"SELECT * FROM table WHERE 1=0"), then PDOStatement->getColumnMeta(0) simply terminates PHP script.

If there is at least one record in the record set, then everythign works all right.

When there are no records, and PHP script dies in PDOStatement->getColumnMeta(), here's what I see in the Postgres log (The statemwent was 
"SELECT * FROM asterisk_huntgroups_memebship WHERE member_id=3", there were no records)

2006-05-04 13:43:05 PDT:asteriskpilot@204.147.182.37(42475) LOG:  statement: SELECT TYPNAME FROM PG_TYPE WHERE OID=0
2006-05-04 13:43:05 PDT:asteriskpilot@204.147.182.37(42475) LOG:  duration: 2.206 ms
2006-05-04 13:43:05 PDT:asteriskpilot@204.147.182.37(42475) LOG:  unexpected EOF on client connection
2006-05-04 13:43:05 PDT:asteriskpilot@204.147.182.37(42475) LOG:  disconnection: session time: 0:27:16.37 user=asteriskpilot database=asteriskpilot host=204.147.182.37 port=42475


Reproduce code:
---------------
Something like this

<?php
$conn = new PDO($connectionString,
                 $username,
                 $password,
                 array(PDO::ATTR_PERSISTENT=>true));
$stmt = $conn->query("SELECT * FROM table WHERE 0=1");

$columnNumber = $stmt->columnCount();
$firstColumn  = $stmt->columnMeta(0); <== dies!

print_r($firstColumn); // never gets to this place
?>









Expected result:
----------------
I expect it to work :)

Actual result:
--------------
Script dies.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-04 18:13 UTC] wez@php.net
Do not use getColumnMeta; it will change in the future.
 [2006-05-04 18:19 UTC] cfilin at intermedia dot net
What should I use instead of getColumknMeta?
 [2006-05-05 00:27 UTC] wez@php.net
The names and values returned from fetch() and fetchAll() are sufficient for the vast majority of PHP applications.  If you really need to query meta information in your application, you can do so by using appropriate SQL queries.
 [2006-05-05 03:18 UTC] cfilin at intermedia dot net
The trouble is that I need meta exactly when there are *no* records in the record set (I need meta to show the names of the columns).

When there are not records, then no names are avaible in the arrays returned by fetch and fetchAll.

-c
 [2006-07-21 17:20 UTC] bugs at xmlnode dot com
I believe you can use fetch(PDO::FETCH_NUM) without data in the table/db.

$row  =  $results->fetch(PDO::FETCH_NUM);
foreach( $row as $k => $v ){
    print_r( $results->getColumnMeta( $k ) );
}
 [2008-09-12 10:55 UTC] johannes at schlueters dot de
What does "die" mean and does the problem still occur with current 5.3 snapshots?
 [2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 13:01:29 2024 UTC