<?
	class conet
	{
		/*////////////// DEFINE THE VARIABLES THAT ARE USED WITHIN THE CLASS //////////////*/
		var $host;
		var $user;
		var $pass;
		var $linkID;
		var $dbID;
		var $numrows;
		var $numfields;
		var $tables;
		var $dbs;
		var $db;
		var $port;
		
		/*////////////// DEFINE CONSTRUCTOR FUNCTION //////////////*/
		function conet($user,$pass,$port,$db,$host)
		{
			$this->user($user);
			$this->pass($pass);
			$this->db($db);
			$this->port($port);
			$this->host($host);
			$this->connect();
		}
		
		/*////////////// DEFINE METHOD FUNCTIONS //////////////*/
		function user($value='')
		{
			if ($value) return $this->user = $value;
			else return $this->user;
		}
		
		function pass($value='')
		{
			if ($value) return $this->pass = $value;
			else return $this->pass;
		}

		function db($value='')
		{
			if($value) return $this->db = $value;
			else return $this->db;
		}

		function port($value='')
		{
			if ($value) return $this->port = $value;
			else return $this->port;
		}

		function host($value='')
		{
			if($value) return $this->host = $value;
			else return $this->host;
		}
		
		function connect()
		{
			if (!$this->linkID = pg_connect("host=$this->host port=$this->port dbname= $this->db user=$this->user password=$this->pass"))
			{
				throw new Exception("ERROR: No se a podido conectar a la base de datos.");
			}
		
			else {
				return;
			}
		}
		
		function close()
		{
			if (empty($this->linkID))
			{
				$this->printError("NA","There are no current postgres connections to close.");
			}
			pg_close($this->linkID);
		}

	};

?>