]> git.openstreetmap.org Git - nominatim.git/blob - lib/db.php
add namedetails and extratags to lookup call
[nominatim.git] / lib / db.php
1 <?php
2         require_once('DB.php');
3
4         function &getDB($bNew = false, $bPersistent = false)
5         {
6                 // Get the database object
7                 $oDB =& DB::connect(CONST_Database_DSN.($bNew?'?new_link=true':''), $bPersistent);
8                 if (PEAR::IsError($oDB))
9                 {
10                         var_dump(CONST_Database_DSN);
11                         var_Dump($oDB);
12                         fail($oDB->getMessage());
13                 }
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");
19                 return $oDB;
20         }
21
22         function getDBQuoted($s)
23         {
24                 return "'".pg_escape_string($s)."'";
25         }
26