]> git.openstreetmap.org Git - nominatim.git/blob - lib/db.php
a2bba81f587be2d40260efa45d8c2c154d04d23f
[nominatim.git] / lib / db.php
1 <?php
2         require_once('DB.php');
3
4         function &getDB()
5         {
6                 // Get the database object
7                 $oDB =& DB::connect(CONST_Database_DSN, 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