| <?php |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DB_PostgreSQL |
| { |
| |
| var $dbconn; |
| |
| |
| |
| function __construct() |
| { |
| $conn_string = 'user=' . DB_USERNAME . ' password=' . DB_PASSWORD . ' dbname=' . DB_DBNAME; |
| $this->dbconn = pg_connect($conn_string) or die("Could not connect"); |
| } |
| |
| |
| |
| function check_connection() |
| { |
| if (pg_connection_status($this->dbconn) === PGSQL_CONNECTION_OK ) |
| { |
| return translate('connected'); |
| } |
| else |
| { |
| return translate('disconnected'); |
| } |
| |
| } |
| |
| |
| |
| function query( $sql_string ) |
| { |
| $result = pg_query( $this->dbconn, $sql_string ); |
| |
| return $result; |
| } |
| |
| |
| |
| function __destruct() |
| { |
| |
| if (pg_connection_status($this->dbconn)) |
| { |
| pg_close($this->dbconn); |
| } |
| |
| } |
| |
| } |
| |
| $db = new DB_PostgreSQL; |
| ?> |