|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-06-14 21:34 UTC] lbutler at intercall dot com
Description:
------------
pg_close() and other pg_ functions unable to reference class variables as link resource. (Works with mysql_connect())
Reproduce code:
---------------
<?php
class databasehandler0
{
var foo;
function connect()
{
$this->foo = pg_connect('host=hostname dbname=database1 user=username1 password=pword1') || die ('An aweful death');
}
function disconnect()
{
pg_close($this->foo);
}
}
$dbconn0 = new databasehandler0;
$dbconn0->connect();
$dbconn0->disconnect();
?>
Expected result:
----------------
I expect to be able to reference the class var foo in pg_close() as a resource connection.
Actual result:
--------------
Warning: pg_close(): supplied argument is not a valid PostgreSQL link resource
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 16:00:01 2025 UTC |
Your code is bogus. $this->foo gets the result of || operation. This works much better :) ($this->foo = pg_connect('host=hostname dbname=database1 user=username1 password=pword1')) || die ('An aweful death');