3 require_once('DB.php');
6 function &getDB($bNew = false, $bPersistent = false)
8 // Get the database object
10 DB::connect(CONST_Database_DSN.($bNew?'?new_link=true':''), $bPersistent),
11 "Failed to establish database connection"
13 $oDB->setFetchMode(DB_FETCHMODE_ASSOC);
14 $oDB->query("SET DateStyle TO 'sql,european'");
15 $oDB->query("SET client_encoding TO 'utf-8'");
16 $iMaxExecution = ini_get('max_execution_time') * 1000;
17 if ($iMaxExecution > 0) $oDB->query("SET statement_timeout TO $iMaxExecution");
21 function getDBQuoted($s)
23 return "'".pg_escape_string($s)."'";
26 function getPostgresVersion(&$oDB)
28 $sVersionString = $oDB->getOne('select version()');
29 preg_match('#PostgreSQL ([0-9]+)[.]([0-9]+)[^0-9]#', $sVersionString, $aMatches);
30 return (float) ($aMatches[1].'.'.$aMatches[2]);
33 function getPostgisVersion(&$oDB)
35 $sVersionString = $oDB->getOne('select postgis_full_version()');
36 preg_match('#POSTGIS="([0-9]+)[.]([0-9]+)[.]([0-9]+)( r([0-9]+))?"#', $sVersionString, $aMatches);
37 return (float) ($aMatches[1].'.'.$aMatches[2]);