Re: Strange behaviour with self written class - Mailing list pgsql-php

From Michael Fork
Subject Re: Strange behaviour with self written class
Date
Msg-id Pine.BSI.4.21.0103050849010.22733-100000@glass.toledolink.com
Whole thread Raw
In response to Strange behaviour with self written class  (Markus Fischer <mfischer@josefine.ben.tuwien.ac.at>)
List pgsql-php
I believe you are running into a well-known PHP bug where multiple
pg_connect's or a pg_connect with multiple pg_pconnect's breaks
(http://bugs.php.net/bugs.php?id=9123).  This has been fixed in CVS, but
here is the patch needed:

-------------------------
(this is from Thies Arntzen, thies@thieso.net, the maintainer of the
Postgres module for PHP)

    i've commited a fix for this to PHP 4 CVS yesterday (~ Feb 15).

    if you don't want to live on the "bleeding edge" (use PHP
    from CVS) just replace the php_pgsql_set_default_link
    function in pgsql.c against this one and you're all-set!

    regards,
    tc

static void php_pgsql_set_default_link(int id)
{
    PGLS_FETCH();

    if ((PGG(default_link) != -1) && (PGG(default_link) != id)) {
        zend_list_delete(PGG(default_link));
    }

    if (PGG(default_link) != id) {
        PGG(default_link) = id;
        zend_list_addref(id);
    }
}
-------------------------

Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio

On Mon, 5 Mar 2001, Markus Fischer wrote:

> Hello,
>
>     I've written a class for the pgsql_* function ( just a
> wrapper to speed up things and have a cleaner interface, I've
> attached it). While working with it, I've made some interesting
> observation :
>
> When create my first instance of the class all works ok; then,
> later in a function in my new php file I create another instance
> of the same class; this time the connection can be established,
> but its somehow corrupted and subsequent queries fail because of
> this:
>
> called dbpg->connect()
> connectstring -> host=XXXXXXXXXXXXXX user=XXXXXX password=XXXXXXX dbname=XXXXXX
> connect() succeeded
> connectLink = resource
> resource(1) of type (pgsql link)
>
> called        <- function called
> called dbpg->connect()
> connectstring -> host=XXXXXXXXXXXXXX user=XXXXXX password=XXXXXXX dbname=XXXXXX
> connect() succeeded
> connectLink = resource
> resource(1) of type (Unknown)
>
> its still of type resource, but its resource type is NOT pgsql
> link like above but 'Unknown'.
>
> Anyone know whats wrong or why this happening ?
>
> thanks
>     Markus
>
> --
> Markus Fischer,  http://josefine.ben.tuwien.ac.at/~mfischer/
> EMail:         mfischer@josefine.ben.tuwien.ac.at
> PGP Public  Key: http://josefine.ben.tuwien.ac.at/~mfischer/C2272BD0.asc
> PGP Fingerprint: D3B0 DD4F E12B F911 3CE1  C2B5 D674 B445 C227 2BD0
>





---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org




pgsql-php by date:

Previous
From: Martín Marqués
Date:
Subject: Re: postgres.h missing?
Next
From: "Mitch Vincent"
Date:
Subject: Re: RE: Sessions without cookies