|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 21:00:01 2025 UTC |
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 ) ); }