getConnection(); } // コネクションハンドルを返す function getConnection() { if ($this->con == false) { return($this->doConnect()); } return($this->con); } function doConnect() { // データベースに接続する // @$this->con = pg_connect($this->hostname,$this->port,$this->dbname);←削除 $conn_string = "host={$this->hostname} dbname={$this->dbname} user={$this->user}"; $this->con = pg_connect($conn_string); if ($this->con == false) { print("データベース $this->dbname に接続できませんでした。"); exit; } return($this->con); } // データベースとの接続切断 function doClose() { if ($this->con != false) { pg_close($this->con); $this->con = false; } } } ?>