Andrew,
What is the open() function?
Best regards,
Andrew
---------------------------------------
Andrew Hill - OpenLink Software
Director Technology Evangelism
eBusiness Infrastructure Technology
http://www.openlinksw.com
On 3/1/01 7:27 PM, "Andrew Halliday" <[EMAIL PROTECTED]> wrote:
> Okay - Im writing an object to wrap a database.
> The key problem is this:
> - it declares a connection var as an object property
> - the open() function opens the connection to the database and stores
> the handle in $this->connection
> - the executeQuery() method complains about not having a valid handle,
> because by then, somehow, $this->connection==null!!!
>
> Any ideas?-i swear its just something stupid ive missed ...
>
> HELP!
>
> Thanx in advance,
> AndrewH
>
> -------------------------------------------------------------
> The code following this returns the following to the browser:
> -------------------------------------------------------------
> The connection in open() is :Resource id #1
> The connection in executeQuery() is :''
>
> Warning: Supplied argument is not a valid PostgreSQL link resource in
> /var/wwwroot/php/PostgreSQLDataSource.php on line 67
>
>
> -------------------------------------------------------------
>
>
> class PostgreSQLDataSource
> {
> var $connection;
> var $lastResultSet;
> var $error_handler;
>
> var $host, $port, $username, $password, $database;
>
> function PostgreSQLDataSource($host, $port, $username, $password,
> $database)
> {
> global $error_handler;
> $this->error_handler = $error_handler;
>
> $this->host = $host;
> $this->port = $port;
> $this->username = $username;
> $this->password = $password;
> $this->database = $database;
>
> //Legacy behaviour: $this->open($host, $port, $username, $password,
> $database);
> }
>
> function open(/*variable arg list*/)
> {
> $connectionString = "";
>
> if (func_num_args() == 5)
> {
> $this->host = func_get_arg(0);
> $this->port = func_get_arg(1);
> $this->username = func_get_arg(2);
> $this->password = func_get_arg(3);
> $this->database = func_get_arg(4);
> }
>
> if ($this->host)
> $connectionString .= " host=".$this->host;
> if ($this->port)
> $connectionString .= " port=".$this->port;
> if ($this->username)
> $connectionString .= " user=".$this->username;
> if ($this->password)
> $connectionString .= " password=".$this->password;
> if ($this->database)
> $connectionString .= " dbname=".$this->database;
>
> $this->connection = pg_Connect($connectionString);
> echo "The connection in open() is :".$this->connection."<BR>";
> if ($this->connection == false)
> return false;
> else
> return true;
> }
>
> function close()
> {
> return pg_Close($this->connection);
> }
>
> function executeQuery($queryString)
> {
> echo "The connection in executeQuery() is :'".$this->connection."'<BR>";
> $this->lastResultSet = pg_exec($this->connection,$queryString);
> return new Iterator($this);
> }
>
> /*PRIVATE FUNCTIONS:*/
> function getRow($row)
> {
> return pg_fetch_array($this->lastResultSet,$row);
> }
>
> function getResultLength()
> {
> return count($this->lastResultSet);
> }
> }
>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]