]> git.openstreetmap.org Git - nominatim.git/blob - lib/db.php
more partitioning work, os open data postcodes, country list fixes
[nominatim.git] / lib / db.php
1 <?php
2         require_once('DB.php');
3
4         function &getDB($bNew = false)
5         {
6                 // Get the database object
7                 $oDB =& DB::connect(CONST_Database_DSN.($bNew?'?new_link=true':''), false);
8                 if (PEAR::IsError($oDB))
9                 {
10                         fail($oDB->getMessage(), 'Unable to connect to the database');
11                 }
12                 $oDB->setFetchMode(DB_FETCHMODE_ASSOC);
13                 $oDB->query("SET DateStyle TO 'sql,european'");
14                 $oDB->query("SET client_encoding TO 'utf-8'");
15                 return $oDB;
16         }
17
18         function getDBQuoted($s)
19         {
20                 return "'".pg_escape_string($s)."'";
21         }
22