forked from learnweb/his_unification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_pg_lite.php
25 lines (20 loc) · 932 Bytes
/
class_pg_lite.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
defined('MOODLE_INTERNAL') || die;
class pg_lite {
public $connection = null;
public function connect() {
$config = "host='".get_config('local_lsf_unification', 'dbhost')."' port ='".get_config('local_lsf_unification', 'dbport')."' user='".get_config('local_lsf_unification', 'dbuser')."' password='".get_config('local_lsf_unification', 'dbpass')."' dbname='".get_config('local_lsf_unification', 'dbname')."'";
ob_start();
$this->connection = pg_connect($config, PGSQL_CONNECT_FORCE_NEW);
$dberr = ob_get_contents();
ob_end_clean();
echo $dberr;
return ((pg_connection_status($this->connection) === false) || (pg_connection_status($this->connection) === PGSQL_CONNECTION_BAD))?$dberr:true;
}
public function dispose() {
if ($this->connection) {
pg_close($this->connection);
$this->connection = null;
}
}
}