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