]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/db.php
more partitioning work, os open data postcodes, country list fixes
[nominatim.git] / lib / db.php
index 4f7336c132b3e4852dc711f7a3ffca13e1ab0c7f..c50b3c404deb4223728b87aae90d6f926e071954 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($bNew = false)
        {
-               fail($oDB->getMessage(), 'Unable to connect to the database');
+               // Get the database object
+               $oDB =& DB::connect(CONST_Database_DSN.($bNew?'?new_link=true':''), 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)
        {