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