php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11130 pg_fetch_array returning twice the number of connections.
Submitted: 2001-05-26 12:36 UTC Modified: 2001-05-26 15:25 UTC
From: excalibur at hub dot org Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 4.0.5 OS: FreeBSD 4.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: excalibur at hub dot org
New email:
PHP Version: OS:

 

 [2001-05-26 12:36 UTC] excalibur at hub dot org
I've tested extensively to figure out if this is a bug or not, but since I installed 4.0.5 on my system my queries have been returning twice the number of columns as it should. The table I am selecting from has 3 rows and 3 columns, however pg_fetch_array returns 6 columns (it creates duplicates). My Query is a simple "SELECT * FROM table ORDER BY column request and I am running 7.1 of PostgreSQL, I have already verified that PostgreSQL is not causing the problem. pg_numfields returns a 3 so I have a work around, but using pg_fetch_array is SOOO convienent :>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-26 12:38 UTC] excalibur at hub dot org
Forgot to add my code..

  function select($query) {
   if (!$this->get_pgsql_connection_status()) {
    $this->open();
   }

   if ($this->get_pgsql_connection_status()) {
    $result_query = pg_exec($this->pgsql_dbh, $query);
    if (isset($result_query) && pg_numrows($result_query) > 0) {
     $result_array = array();
     for ($i = 0; $i < pg_numrows($result_query); $i++) {
      $result_array[$i] = pg_fetch_array($result_query, $i);
     }

     $this->close();
     return $result_array;
    }

    $this->close();
   }

   return false;
  }
 [2001-05-26 15:25 UTC] derick@php.net
This is not a bug, see this in the manual: (www.php.net/pg_fetch_array)

   Pg_fetch_array() is an extended version of pg_fetch_row(). In addition
   to storing the data in the numeric indices of the result array, it
   also stores the data in associative indices, using the field names as
   keys.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Sep 20 10:00:01 2025 UTC