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 getArraySQL($a)
28 return 'ARRAY['.join(',', $a).']';
31 function getPostgresVersion(&$oDB)
33 $sVersionString = $oDB->getOne('select version()');
34 preg_match('#PostgreSQL ([0-9]+)[.]([0-9]+)[^0-9]#', $sVersionString, $aMatches);
35 return (float) ($aMatches[1].'.'.$aMatches[2]);
38 function getPostgisVersion(&$oDB)
40 $sVersionString = $oDB->getOne('select postgis_full_version()');
41 preg_match('#POSTGIS="([0-9]+)[.]([0-9]+)[.]([0-9]+)( r([0-9]+))?"#', $sVersionString, $aMatches);
42 return (float) ($aMatches[1].'.'.$aMatches[2]);