Index: src/webservice/htdocs/SiWeather/Webservice/DatabaseHandler.php
===================================================================
--- src/webservice/htdocs/SiWeather/Webservice/DatabaseHandler.php	(revision b38cc03298dec5a29ccdad110e181c545968e4a6)
+++ src/webservice/htdocs/SiWeather/Webservice/DatabaseHandler.php	(revision b5ebb8df50cf75e9fd286740f30b7f4334d5a14a)
@@ -35,6 +35,5 @@
 		$this->_database = null;
 		if(!$this->_config->dataDirectory()){
-			$this->_lastErrorMessage = "No data directory set!";
-			error_log("Could not connect to the database: "+ $this->lastErrorMessage());
+			$this->setLastErrorMessage("Could not connect to the database: No data directory set!");
 			$this->databaseFile = null;
 		}
@@ -61,4 +60,16 @@
 	}
 
+	public function lastDatabaseErrorMessage(){
+		if(is_null($this->_database))
+			return false;
+		return $this->_database->lastErrorMsg();
+	}
+
+	public function lastInsertRowId(){
+		if(is_null($this->_database))
+			return -1;
+		return $this->_database->lastInsertRowID();
+	}
+
 	public function connect()
 	{
@@ -67,6 +78,5 @@
 		}
 		if(is_null($this->_databaseFile) || empty($this->_databaseFile)){
-			$this->_lastErrorMessage = "No database file given";
-			error_log("Could not connect to the database: "+ $this->lastErrorMessage());
+			$this->setLastErrorMessage("Could not connect to the database: No database file given");
 			return false;
 		}
@@ -75,6 +85,5 @@
 		}
 		catch(\Exception $exception){
-			$this->_lastErrorMessage = $exception->getMessage();
-			error_log("Could not connect to the database: "+ $this->lastErrorMessage());
+			$this->setLastErrorMessage("Could not connect to the database: "+ $exception->getMessage());
 			return false;
 		}
@@ -82,11 +91,9 @@
 		$extension = $this->_config->getConfig("spatialiteExtension");
 		if(empty($extension)){
-			$this->_lastErrorMessage("No spatialiteExtension set!");
-			error_log($this->lastErrorMessage());
+			$this->setLastErrorMessage("No spatialiteExtension set!");
 			return false;
 		}
 		if(!$db->loadExtension($extension)){
-			$this->_lastErrorMessage = "Could not load SpatialLite extension: ". $db->lastErrorMsg();
-			error_log($this->lastErrorMessage());
+			$this->setLastErrorMessage("Could not load SpatialLite extension: ". $db->lastErrorMsg());
 			return false;
 		}
@@ -104,6 +111,5 @@
 			return true;
 		}
-		$this->_lastErrorMessage = $this->_database->lastErrorMsg();
-		error_log("Failed to close the database: "+ $this->lastErrorMessage());
+		$this->setLastErrorMessage("Failed to close the database: "+ $this->_database->lastErrorMsg());
 		return false;
 	}
@@ -117,5 +123,8 @@
 			return false;
 		}
-		return $this->_database->exec($query);
+		$result = $this->_database->exec($query);
+		if(!$result)
+			$this->setLastErrorMessage("Could not execute databae query \"". $query ."\": ". $this->_database->lastErrorMsg());
+		return $result;
 	}
 	
@@ -128,10 +137,15 @@
 			return false;
 		}
-		return $this->_database->prepare($query);
+		$result = $this->_database->prepare($query);
+		if(!$result){
+			error_log("logging");
+			$this->setLastErrorMessage("Could not prepare database query \"". $query ."\": ". $this->_database->lastErrorMsg());
+		}
+		return $result;
 	}
 	
 	public function versionSpatialite(){
 		if(is_null($this->_database)){
-			$this->_lastErrorMessage = "Unknown (No database connection)";
+			$this->setLastErrorMessage("Unknown (No database connection)");
 			return 0;
 		}
@@ -148,5 +162,5 @@
 	public function versionSqlite(){
 		if(is_null($this->_database)){
-			$this->_lastErrorMessage = "Unknown (No database connection)";
+			$this->setLastErrorMessage("Unknown (No database connection)");
 			return 0;
 		}
@@ -160,4 +174,10 @@
 		return 0;
 	}
+
+	private function setLastErrorMessage($message){
+		if(!empty($message))
+			error_log($message);
+		$this->_lastErrorMessage = $message;
+	}
 	
 	private $_database;
