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