<?php

class Pgsql implements iDbDriver {

	private $_connection = false;
	
	public function connect($host, $port, $dbname, $login, $pass) {
		$this->connection = pg_connect('host='. $host .' port='. $port .' dbname='. $dbname .' user='. $login .' password='. $pass);
	}

	public function q($q) {
		return pg_query($q);
	}
	
	public function getRows($r, $key = false) {
		$rows = array();
		while($row = pg_fetch_assoc($r)) {
			if (!$key) {
				$rows[] = $row;
			} else {
				$rows[$row[$key]] = $row;
			}
		}
		return $rows;
	}
	
	public function getRow($r) {
		return pg_fetch_assoc($r);
	}
}

?>