[Mapbender-commits] r6977 - branches/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Sep 29 14:40:59 EDT 2010


Author: christoph
Date: 2010-09-29 18:40:59 +0000 (Wed, 29 Sep 2010)
New Revision: 6977

Added:
   branches/mapbender/lib/class_Mapbender_database.php
Log:
pdo

Added: branches/mapbender/lib/class_Mapbender_database.php
===================================================================
--- branches/mapbender/lib/class_Mapbender_database.php	                        (rev 0)
+++ branches/mapbender/lib/class_Mapbender_database.php	2010-09-29 18:40:59 UTC (rev 6977)
@@ -0,0 +1,44 @@
+<?php
+/**
+ * manages the database access 
+ * @class
+ */
+ 
+ require_once dirname(__FILE__)."/../http/classes/class_mb_exception.php";
+ require_once dirname(__FILE__)."/../http/classes/class_mb_warning.php";
+ require_once dirname(__FILE__)."/../http/classes/class_mb_notice.php";
+
+ class Mapbender_database {
+ 	
+	private static $instance;
+	private $con;
+ 	
+ 	/**
+	 * @constructor
+	 */
+ 	protected function __construct() {
+		$this->connect();
+ 	}
+
+ 	public static function singleton() {
+		if (!isset(self::$instance)) {
+			self::$instance = new Mapbender_database();
+		}
+		return self::$instance;
+    	}
+	
+	public function connect($pdo = null) {
+		if (is_null($pdo)) {
+			$this->con = new PDO("pgsql:host=" . DBSERVER . ";port=" . PORT . ";dbname=" . DB . ";user=" . OWNER . ";password=" . PW);
+		}
+		else {
+			$this->con = $pdo;
+		}
+	}
+
+	public function db() {
+		return $this->con;
+	}
+ 	
+ }
+?>



More information about the Mapbender_commits mailing list