]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/db.php
hstore names / refactoring
[nominatim.git] / lib / db.php
index 4f7336c132b3e4852dc711f7a3ffca13e1ab0c7f..a2bba81f587be2d40260efa45d8c2c154d04d23f 100644 (file)
@@ -1,15 +1,19 @@
 <?php
        require_once('DB.php');
 
-       // Get the database object
-       $oDB =& DB::connect(CONST_Database_DSN, false);
-       if (PEAR::IsError($oDB))
+       function &getDB()
        {
-               fail($oDB->getMessage(), 'Unable to connect to the database');
+               // Get the database object
+               $oDB =& DB::connect(CONST_Database_DSN, false);
+               if (PEAR::IsError($oDB))
+               {
+                       fail($oDB->getMessage(), 'Unable to connect to the database');
+               }
+               $oDB->setFetchMode(DB_FETCHMODE_ASSOC);
+               $oDB->query("SET DateStyle TO 'sql,european'");
+               $oDB->query("SET client_encoding TO 'utf-8'");
+               return $oDB;
        }
-       $oDB->setFetchMode(DB_FETCHMODE_ASSOC);
-       $oDB->query("SET DateStyle TO 'sql,european'");
-       $oDB->query("SET client_encoding TO 'utf-8'");
 
        function getDBQuoted($s)
        {