Ask a Question related to PHP Development, Design and Development.
-
steven at pearavenue dot com #1
#26132 [NEW]: pg_fetch_object returns NULL on serial and INT in record but returns strings NP
From: steven at pearavenue dot com
Operating system: Redhat 9.0/Apache 2.0
PHP version: 4.3.4
PHP Bug Type: PostgreSQL related
Bug description: pg_fetch_object returns NULL on serial and INT in record but returns strings NP
Description:
------------
I checked on PHP 5.0beta too and the same problem there. pg_fetch_object
returns serial or integers as NULL while but returns varchars in the same
record as string - pg_fetch_array returns the entire data correctly.
Similar code worked fine on another server using MySQl Support.
You need a table like this:
CREATE TABLE public.feeds
(
feedid serial NOT NULL,
uri varchar(255) NOT NULL DEFAULT '',
category int4 NOT NULL DEFAULT 0,
CONSTRAINT feeds_pkey PRIMARY KEY (feedid),
CONSTRAINT feeds_uri_key UNIQUE (uri)
) WITH OIDS;
Reproduce code:
---------------
<?php
$pgConnectStr = "... your connect string";
$link = pg_connect( $pgConnectStr ) or die( "Could not connect" );
$stat = pg_connection_status($link);
if($stat == PGSQL_CONNECTION_OK ) {
echo "connection_status: OK<br />";
} else {
// report connection error
echo "connection_status: BAD<br />";
echo( pg_last_error($link) );
}
$feedb = pg_query( $link, $sql);
echo( "<br />".pg_num_rows( $feedb )." Number of rows returned.<br />" );
// for each row in the table stuff the coresponding variables with the
data:
echo ( "ARRAY<br />" );
while( $fields = pg_fetch_array( $feedb ) ){
echo ( "<br />Feed[0]: $fields[0]<br />" );
echo ( "<br />Feed[1]: {$fields[1]}<br />" );
echo ( "<br />Feed[2]: {$fields[2]}<br />" );
}
echo ( "OBJECT<br />" );
while( $row = pg_fetch_object( $feedb ) ){
if( $row->FeedID == NULL) {
$id = "NULL";
} else {
$id = $row->FeedID;
}
echo ( "<br />FeedID:".$id."<br />" );
$uri = $row->uri;
echo ( "<br />uri: $uri<br />" );
if( $row->category == NULL) {
$c = "NULL";
} else {
$c = $row->category;
}
echo ( "<br />category: $c<br />" );
}
?>
Expected result:
----------------
We expect the serial and integer values to appear in the result from
pg_fetch_object
Actual result:
--------------
You will note that the output produces NULLs instead.
--
Edit bug report at [url]http://bugs.php.net/?id=26132&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=26132&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=26132&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=26132&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=26132&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=26132&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=26132&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=26132&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=26132&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=26132&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=26132&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=26132&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=26132&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=26132&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=26132&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=26132&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=26132&r=float[/url]
steven at pearavenue dot com Guest
-
#26349 [Bgs]: is_numeric() returns false for strings with more than 308 characters
ID: 26349 User updated by: kouber at saparev dot com Reported By: kouber at saparev dot com Status: Bogus Bug Type:... -
#26132 [Bgs]: pg_fetch_object returns NULL on serial and INT in record but returns strings NP
ID: 26132 User updated by: steven at pearavenue dot com Reported By: steven at pearavenue dot com Status: Bogus Bug... -
#26132 [Opn->Bgs]: pg_fetch_object returns NULL on serial and INT in record but returns strings NP
ID: 26132 Updated by: iliaa@php.net Reported By: steven at pearavenue dot com -Status: Open +Status: ... -
#26132 [Opn]: pg_fetch_object returns NULL on serial and INT in record but returns strings NP
ID: 26132 User updated by: steven at pearavenue dot com Reported By: steven at pearavenue dot com Status: Open Bug... -
Returns a NULL field ?
Hi. I'm stuck! I am querying two tables in a DB using the following string SQLQuery = "SELECT GuestBook.*, GuestPic.PicName FROM GuestBook...



Reply With Quote

