2 require_once('DB.php');
4 function &getDB($bNew = false, $bPersistent = false)
6 // Get the database object
7 $oDB = DB::connect(CONST_Database_DSN.($bNew?'?new_link=true':''), $bPersistent);
8 if (PEAR::IsError($oDB))
10 var_dump(CONST_Database_DSN);
12 fail($oDB->getMessage());
14 $oDB->setFetchMode(DB_FETCHMODE_ASSOC);
15 $oDB->query("SET DateStyle TO 'sql,european'");
16 $oDB->query("SET client_encoding TO 'utf-8'");
17 $iMaxExecution = ini_get('max_execution_time') * 1000;
18 if ($iMaxExecution > 0) $oDB->query("SET statement_timeout TO $iMaxExecution");
22 function getDBQuoted($s)
24 return "'".pg_escape_string($s)."'";
27 function getPostgresVersion(&$oDB)
29 $sVersionString = $oDB->getOne('select version()');
30 preg_match('#PostgreSQL ([0-9]+)[.]([0-9]+)[^0-9]#', $sVersionString, $aMatches);
31 return (float) ($aMatches[1].'.'.$aMatches[2]);
34 function getPostgisVersion(&$oDB)
36 $sVersionString = $oDB->getOne('select postgis_full_version()');
37 preg_match('#POSTGIS="([0-9]+)[.]([0-9]+)[.]([0-9]+)( r([0-9]+))?"#', $sVersionString, $aMatches);
38 return (float) ($aMatches[1].'.'.$aMatches[2]);