Added Other AP
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
class Db {
|
||||
|
||||
private $conn;
|
||||
private $conn_gps;
|
||||
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
public function getConnect() {
|
||||
global $savvyext;
|
||||
if ($this->conn==NULL || !pg_version($this->conn)) {
|
||||
$db_host = $savvyext->cfgReadChar('database.host');
|
||||
$db_name = $savvyext->cfgReadChar('database.name');
|
||||
$db_user = $savvyext->cfgReadChar('database.user');
|
||||
$db_pass = $savvyext->cfgReadChar('database.pass');
|
||||
$db_port = $savvyext->cfgReadLong('database.port');
|
||||
$connstr = "host=${db_host} port=${db_port} dbname=${db_name} user=${db_user} password=${db_pass}";
|
||||
$this->conn = pg_connect($connstr);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
public function getConnectGPS() {
|
||||
global $savvyext;
|
||||
if ($this->conn_gps==NULL || !pg_version($this->conn_gps)) {
|
||||
$db_host = $savvyext->cfgReadChar('gpsdatabase.host');
|
||||
$db_name = $savvyext->cfgReadChar('gpsdatabase.name');
|
||||
$db_user = $savvyext->cfgReadChar('gpsdatabase.user');
|
||||
$db_pass = $savvyext->cfgReadChar('gpsdatabase.pass');
|
||||
$db_port = $savvyext->cfgReadLong('gpsdatabase.port');
|
||||
$connstr = "host=${db_host} port=${db_port} dbname=${db_name} user=${db_user} password=${db_pass}";
|
||||
$this->conn_gps = pg_connect($connstr);
|
||||
}
|
||||
return $this->conn_gps;
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
if(!empty($this->conn)){
|
||||
pg_close($this->conn);
|
||||
}
|
||||
if(!empty($this->conn_gps)){
|
||||
pg_close($this->conn_gps);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// vi:ts=2
|
||||
|
||||
Reference in New Issue
Block a user