db_host = $str_host; $this->db_port = $int_port; $this->db_name = $str_dbname; $this->db_username = $str_username; $this->db_passwd = $str_passwd; // execute connection $this->connect(); } /** * Method to invoke connection to RDBMS * * @return void */ private function connect() { $this->res_conn = @pg_connect("host=".$this->db_host." dbname=".$this->db_name. " user=".$this->db_username. " password=".$this->db_passwd. " port=".$this->db_port); if (!$this->res_conn) { $this->error = "Database fail to connected. \n".pg_last_error($this->res_conn); parent::showError(true); } } /** * Method to create/send query to RDBMS * * @param string $str_query * @return object */ public function query($str_query = '') { if (empty($str_query)) { $this->error = 'Cant send query because query was empty'; parent::showError(true); } else { $_result = new simbio_pgsql_result($str_query, $this->res_conn); // get any properties from result object $this->affected_rows = $_result->affected_rows; $this->errno = $_result->errno; $this->error = $_result->error; $this->insert_id = $_result->insert_id; // return the result object if ($this->error) { return false; } else { return $_result; } } } /** * Method to escape SQL string * * @param string $str_data * @return string */ public function escape_string($str_data) { return pg_escape_string($this->res_conn, $str_data); } /** * Method to close RDBMS connection * * @return void */ public function close() { pg_close($this->res_conn); } } ?>