-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathpgsql.inc
More file actions
47 lines (43 loc) · 1018 Bytes
/
pgsql.inc
File metadata and controls
47 lines (43 loc) · 1018 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* php -mod-pgsql test/generic functions
*/
/** ---------------------------------- Tests functions -------------------------------------------- */
static $pgconn=null;
function get_pgsql_conn()
{
global $ppgconn;
$cfg = array(
'host'=>'localhost',
'port'=>5432,
'dbname'=>'sbtest',
'user'=>'sbtest',
'password'=>'123',
);
if (is_file('pgsql-conn.ini')){
$cfg=parse_ini_file('pgsql-conn.ini');
// print_r($cfg);
}
// print_r($cfg);
$conn = "host=${cfg['host']}"
." port=${cfg['port']}"
." dbname=${cfg['dbname']}"
." user=${cfg['user']}"
." password=${cfg['password']}";
// print("pgconn:$conn\n");
$pgconn = pg_connect($conn);
return $pgconn;
}
function get_pgsql_version()
{
$c = get_pgsql_conn();
if ($c){
if (PHP_VERSION<'5.0')return '-.-.-';
$info = pg_version($c);
// print_r($info);
if (isset($info["server"]))
return 'server: '.$info["server"].'; client: '.$info['client'];
return 'client: '.$info["client"];
}
return false;
}