Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 1997)
+++ branches/2.8.x/CHANGELOG	(revision 1998)
@@ -11,6 +11,9 @@
 ! = Update/Change
 ===============================================================================
 
+13 Nov-2013 Build 1998 Manuela v.d.Decken(DarkViper)
++ WbDatabase added new methods fetchObject(), rewind(), seekRow(), freeResult()
+! renamed some methods and add aliases for the old names
 09 Nov-2013 Build 1997 Dietmar Woellbrink (Luisehahne)
 # /modules/droplets/droplets.functions.php::prepareDropletToFile   added missing forward droplet flag into description text
 09 Nov-2013 Build 1996 Dietmar Woellbrink (Luisehahne)
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 1997)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 1998)
@@ -51,5 +51,5 @@
 
 // check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
 if(!defined('VERSION')) define('VERSION', '2.8.3');
-if(!defined('REVISION')) define('REVISION', '1997');
+if(!defined('REVISION')) define('REVISION', '1998');
 if(!defined('SP')) define('SP', '');
Index: branches/2.8.x/wb/framework/WbDatabase.php
===================================================================
--- branches/2.8.x/wb/framework/WbDatabase.php	(revision 1997)
+++ branches/2.8.x/wb/framework/WbDatabase.php	(revision 1998)
@@ -20,9 +20,9 @@
  *
  * @category     Core
  * @package      Core_database
- * @author       Werner v.d.Decken <wkl@isteam.de>
+ * @author       Manuela v.d.Decken <manuela@isteam.de>
  * @author       Dietmar W. <dietmar.woellbrink@websitebaker.org>
- * @copyright    Werner v.d.Decken <wkl@isteam.de>
+ * @copyright    Manuela v.d.Decken <manuela@isteam.de>
  * @license      http://www.gnu.org/licenses/gpl.html   GPL License
  * @version      0.0.9
  * @revision     $Revision$
@@ -38,9 +38,9 @@
 
 	private static $_oInstances = array();
 
-	private $_db_handle  = null; // readonly from outside
-	private $_db_name    = '';
-	private $_sInstanceIdentifier = '';
+	protected $oDbHandle    = null; // readonly from outside
+	protected $sDbName      = '';
+	protected $sInstanceIdentifier = '';
 	protected $sTablePrefix = '';
 	protected $sCharset     = '';
 	protected $connected    = false;
@@ -48,20 +48,26 @@
 	protected $error_type   = '';
 	protected $iQueryCount  = 0;
 
-/* prevent from public instancing */
+/**
+ * __constructor
+ *  prevent from public instancing
+ */
 	protected function  __construct() {}
-/* prevent from cloning */
+/**
+ * prevent from cloning
+ */
 	private function __clone() {}
 /**
  * get a valid instance of this class
  * @param string $sIdentifier selector for several different instances
- * @return object
+ * @return WbDatabase object
  */
-	public static function getInstance($sIdentifier = 'core') {
+	public static function getInstance($sIdentifier = 'core')
+	{
 		if( !isset(self::$_oInstances[$sIdentifier])) {
             $c = __CLASS__;
 			$oInstance = new $c;
-			$oInstance->_sInstanceIdentifier = $sIdentifier;
+			$oInstance->sInstanceIdentifier = $sIdentifier;
             self::$_oInstances[$sIdentifier] = $oInstance;
 		}
 		return self::$_oInstances[$sIdentifier];
@@ -68,9 +74,10 @@
 	}
 /**
  * disconnect and kills an existing instance
- * @param string $sIdentifier
+ * @param string $sIdentifier selector for instance to kill
  */
-	public static function killInstance($sIdentifier) {
+	public static function killInstance($sIdentifier)
+	{
 		if($sIdentifier != 'core') {
 			if( isset(self::$_oInstances[$sIdentifier])) {
 				self::$_oInstances[$sIdentifier]->disconnect();
@@ -79,18 +86,20 @@
 		}
 	}
 /**
- * Connect to the database
+ * Establish connection
  * @param string $url
  * @return bool
- *
- * Example for SQL-Url:  'mysql://user:password@demo.de[:3306]/datenbank'
+ * @throws WbDatabaseException
+ * @description opens a connection using connect URL<br />
+ *              Example for SQL-Url:  'mysql://user:password@example.com[:3306]/database?charset=utf8&tableprefix=xx_'
  */
-	public function doConnect($url = '') {
-		if($this->connected) { return $this->connected; } // prevent from reconnecting
+	public function doConnect($url = '')
+	{
+		if ($this->connected) { return $this->connected; } // prevent from reconnecting
 		$this->connected = false;
-		if($url != '') {
+		if ($url != '') {
+		// parse URL and extract connection data
 			$aIni = parse_url($url);
-			
 			$scheme   = isset($aIni['scheme']) ? $aIni['scheme'] : 'mysql';
 			$hostname = isset($aIni['host']) ? $aIni['host'] : '';
 			$username = isset($aIni['user']) ? $aIni['user'] : '';
@@ -100,9 +109,9 @@
 			$db_name  = ltrim(isset($aIni['path']) ? $aIni['path'] : '', '/\\');
 			$sTmp = isset($aIni['query']) ? $aIni['query'] : '';
 			$aQuery = explode('&', $sTmp);
-			foreach($aQuery as $sArgument) {
+			foreach ($aQuery as $sArgument) {
 				$aArg = explode('=', $sArgument);
-				switch(strtolower($aArg[0])) {
+				switch (strtolower($aArg[0])) {
 					case 'charset':
 						$this->sCharset = strtolower(preg_replace('/[^a-z0-9]/i', '', $aArg[1]));
 						break;
@@ -113,25 +122,22 @@
 						break;
 				}
 			}
-			$this->_db_name = $db_name;
-		}else {
+			$this->sDbName = $db_name;
+		} else {
 			throw new WbDatabaseException('Missing parameter: unable to connect database');
 		}
-		$this->_db_handle = @mysql_connect($hostname.$hostport,
-		                                   $username,
-		                                   $password,
-		                                   true);
-		if(!$this->_db_handle) {
-			throw new WbDatabaseException('unable to connect \''.$scheme.'://'.
-			                           $hostname.$hostport.'\'');
+		$this->oDbHandle = @mysql_connect($hostname.$hostport, $username, $password, true);
+		if (!$this->oDbHandle) {
+			throw new WbDatabaseException('unable to connect \''.$scheme.'://'.$hostname.$hostport.'\'');
 		} else {
-			if(!@mysql_select_db($db_name, $this->_db_handle)) {
+			if (!@mysql_select_db($db_name, $this->oDbHandle)) {
 				throw new WbDatabaseException('unable to select database \''.$db_name.
-				                           '\' on \''.$scheme.'://'.
-				                           $hostname.$hostport.'\'');
+				                              '\' on \''.$scheme.'://'.
+				                              $hostname.$hostport.'\''
+				                             );
 			} else {
-				if($this->sCharset) {
-					@mysql_query('SET NAMES \''.$this->sCharset.'\'', $this->_db_handle);
+				if ($this->sCharset) {
+					@mysql_query('SET NAMES \''.$this->sCharset.'\'', $this->oDbHandle);
 				}
 				$this->connected = true;
 			}
@@ -138,62 +144,113 @@
 		}
 		return $this->connected;
 	}
-
-	// Disconnect from the database
-	public function disconnect() {
-		if($this->connected == true && $oInstance->_sInstanceIdentifier != 'core' ) {
-			mysql_close($this->_db_handle);
+/**
+ * disconnect database
+ * @return bool
+ * @description Disconnect current object from the database<br />
+ *              the 'core' connection can NOT be disconnected!
+ */
+	public function disconnect()
+	{
+		if ($this->connected == true && $oInstance->sInstanceIdentifier != 'core') {
+			mysql_close($this->oDbHandle);
 			$this->connected = false;
 			return true;
 		}
 		return false;
 	}
-
-	// Run a query
-	public function query($statement) {
+/**
+ * Alias for doQuery()
+ */
+	public function query($statement)
+	{
+		return $this->doQuery($statement);
+	}
+/**
+ * execute query
+ * @param string $statement the SQL-statement to execute
+ * @return null|\mysql
+ */
+	public function doQuery($statement) {
 		$this->iQueryCount++;
 		$mysql = new mysql();
-		$mysql->query($statement, $this->_db_handle);
-		$this->set_error($mysql->error($this->_db_handle));
-		if($mysql->error($this->_db_handle)) {
+		$mysql->query($statement, $this->oDbHandle);
+		$this->set_error($mysql->error($this->oDbHandle));
+		if ($mysql->error($this->oDbHandle)) {
 			return null;
 		} else {
 			return $mysql;
 		}
 	}
-
-	// Gets the first column of the first row
+/**
+ * Alias for getOne()
+ */
 	public function get_one( $statement )
 	{
+		return $this->getOne($statement);
+	}
+	// Gets the first column of the first row
+/**
+ * Gets the first column of the first row
+ * @param string $statement  SQL-statement
+ * @return null|mixed
+ */
+	public function getOne( $statement )
+	{
 		$this->iQueryCount++;
-		$fetch_row = mysql_fetch_array(mysql_query($statement, $this->_db_handle));
+		$fetch_row = mysql_fetch_array(mysql_query($statement, $this->oDbHandle));
 		$result = $fetch_row[0];
-		$this->set_error(mysql_error($this->_db_handle));
-		if(mysql_error($this->_db_handle)) {
+		$this->set_error(mysql_error($this->oDbHandle));
+		if (mysql_error($this->oDbHandle)) {
 			return null;
 		} else {
 			return $result;
 		}
 	}
-
+/**
+ * Alias for setError()
+ */
+	public function set_error($message = null)
+	{
+		$this->setError($message = null);
+	}
 	// Set the DB error
-	public function set_error($message = null) {
-		global $TABLE_DOES_NOT_EXIST, $TABLE_UNKNOWN;
+/**
+ * setError
+ * @param string $message
+ */
+	public function setError($message = null)
+	{
 		$this->error = $message;
-		if(strpos($message, 'no such table')) {
-			$this->error_type = $TABLE_DOES_NOT_EXIST;
-		} else {
-			$this->error_type = $TABLE_UNKNOWN;
-		}
 	}
-
-	// Return true if there was an error
-	public function is_error() {
+/**
+ * Alias for isError
+ */
+	public function is_error()
+	{
+		return $this->isError();
+	}
+/**
+ * isError
+ * @return bool
+ */
+	public function isError()
+	{
 		return (!empty($this->error)) ? true : false;
 	}
-
-	// Return the error
-	public function get_error() {
+/**
+ * Alias for getError
+ */
+	public function get_error()
+	{
+		return $this->getError();
+	}
+/**
+ * get last Error
+ * @return string
+ */
+	public function getError()
+	{
 		return $this->error;
 	}
 /**
@@ -202,43 +259,44 @@
  * @param mixed value
  * @throws WbDatabaseException
  */	
-	public function __set($name, $value) {
+	public function __set($name, $value)
+	{
 		throw new WbDatabaseException('tried to set a readonly or nonexisting property ['.$name.']!! ');
 	}
 /**
  * default Getter for some properties
  * @param string name of the Property
- * @return mixed NULL on error or missing property
+ * @return NULL on error | valid property
  */
 	public function __get($sPropertyName)
 	{
-		switch ($sPropertyName):
-			case 'db_handle':
+		switch ($sPropertyName) {
 			case 'DbHandle':
-			case 'getDbHandle':
-				$retval = $this->_db_handle;
+			case 'getDbHandle': // << set deprecated
+			case 'db_handle': // << set deprecated
+				$retval = $this->oDbHandle;
 				break;
 			case 'LastInsertId':
-			case 'getLastInsertId':
-				$retval = mysql_insert_id($this->_db_handle);
+			case 'getLastInsertId': // << set deprecated
+				$retval = mysql_insert_id($this->oDbHandle);
 				break;
-			case 'db_name':
 			case 'DbName':
-			case 'getDbName':
-				$retval = $this->_db_name;
+			case 'getDbName': // << set deprecated
+			case 'db_name': // << set deprecated
+				$retval = $this->sDbName;
 				break;
 			case 'TablePrefix':
-			case 'getTablePrefix':
+			case 'getTablePrefix': // << set deprecated
 				$retval = $this->sTablePrefix;			
 				break;
 			case 'QueryCount':
-			case 'getQueryCount':
+			case 'getQueryCount': // << set deprecated
 				$retval = $this->iQueryCount;
 				break;
 			default:
 				$retval = null;
 				break;
-		endswitch;
+		}
 		return $retval;
 	} // __get()
 /**
@@ -248,7 +306,7 @@
  */
 	public function escapeString($unescaped_string)
 	{
-		return mysql_real_escape_string($unescaped_string, $this->_db_handle);
+		return mysql_real_escape_string($unescaped_string, $this->oDbHandle);
 	}
 /**
  * Last inserted Id
@@ -256,49 +314,65 @@
  */	
 	public function getLastInsertId()
 	{
-		return mysql_insert_id($this->_db_handle);
+		return mysql_insert_id($this->oDbHandle);
 	}
+/**
+ * Alias for isField()
+ */
+	public function field_exists($table_name, $field_name)
+	{
+		return $this->isField($table_name, $field_name);
+	}
 /*
  * @param string full name of the table (incl. TABLE_PREFIX)
  * @param string name of the field to seek for
  * @return bool true if field exists
  */
-	public function field_exists($table_name, $field_name)
+	public function isField($table_name, $field_name)
 	{
 		$sql = 'DESCRIBE `'.$table_name.'` `'.$field_name.'` ';
-		$query = $this->query($sql, $this->_db_handle);
+		$query = $this->query($sql, $this->oDbHandle);
 		return ($query->numRows() != 0);
 	}
+/**
+ * Alias for isIndex()
+ */
+	public function index_exists($table_name, $index_name, $number_fields = 0)
+	{
+		return $this->isIndex($table_name, $index_name, $number_fields = 0);
+	}
 /*
+ * isIndex
  * @param string full name of the table (incl. TABLE_PREFIX)
  * @param string name of the index to seek for
  * @return bool true if field exists
  */
-	public function index_exists($table_name, $index_name, $number_fields = 0)
+	public function isIndex($table_name, $index_name, $number_fields = 0)
 	{
 		$number_fields = intval($number_fields);
 		$keys = 0;
 		$sql = 'SHOW INDEX FROM `'.$table_name.'`';
-		if( ($res_keys = $this->query($sql, $this->_db_handle)) )
-		{
-			while(($rec_key = $res_keys->fetchRow()))
-			{
-				if( $rec_key['Key_name'] == $index_name )
-				{
+		if (($res_keys = $this->doQuery($sql, $this->oDbHandle))) {
+			while (($rec_key = $res_keys->fetchRow(MYSQL_ASSOC))) {
+				if ( $rec_key['Key_name'] == $index_name ) {
 					$keys++;
 				}
 			}
 
 		}
-		if( $number_fields == 0 )
-		{
+		if ( $number_fields == 0 ) {
 			return ($keys != $number_fields);
-		}else
-		{
+		} else {
 			return ($keys == $number_fields);
 		}
 	}
-
+/**
+ * Alias for addField()
+ */
+	public function field_add($table_name, $field_name, $description)
+	{
+		return $this->addField($table_name, $field_name, $description);
+	}
 /*
  * @param string full name of the table (incl. TABLE_PREFIX)
  * @param string name of the field to add
@@ -305,24 +379,28 @@
  * @param string describes the new field like ( INT NOT NULL DEFAULT '0')
  * @return bool true if successful, otherwise false and error will be set
  */
-	public function field_add($table_name, $field_name, $description)
+	public function addField($table_name, $field_name, $description)
 	{
-		if( !$this->field_exists($table_name, $field_name) )
-		{ // add new field into a table
+		if (!$this->isField($table_name, $field_name)) {
+		// add new field into a table
 			$sql = 'ALTER TABLE `'.$table_name.'` ADD '.$field_name.' '.$description.' ';
-			$query = $this->query($sql, $this->_db_handle);
-			$this->set_error(mysql_error($this->_db_handle));
-			if( !$this->is_error() )
-			{
-				return ( $this->field_exists($table_name, $field_name) ) ? true : false;
+			$query = $this->doQuery($sql, $this->oDbHandle);
+			$this->set_error(mysql_error($this->oDbHandle));
+			if (!$this->isError()) {
+				return ( $this->isField($table_name, $field_name) ) ? true : false;
 			}
-		}else
-		{
+		} else {
 			$this->set_error('field \''.$field_name.'\' already exists');
 		}
 		return false;
 	}
-
+/**
+ * Alias for modifyField()
+ */
+	public function field_modify($table_name, $field_name, $description)
+	{
+		return $this->modifyField($table_name, $field_name, $description);
+	}
 /*
  * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
  * @param string $field_name: name of the field to add
@@ -329,34 +407,46 @@
  * @param string $description: describes the new field like ( INT NOT NULL DEFAULT '0')
  * @return bool: true if successful, otherwise false and error will be set
  */
-	public function field_modify($table_name, $field_name, $description)
+	public function modifyField($table_name, $field_name, $description)
 	{
 		$retval = false;
-		if( $this->field_exists($table_name, $field_name) )
-		{ // modify a existing field in a table
+		if ($this->isField($table_name, $field_name)) {
+		// modify a existing field in a table
 			$sql  = 'ALTER TABLE `'.$table_name.'` MODIFY `'.$field_name.'` '.$description;
-			$retval = ( $this->query($sql, $this->_db_handle) ? true : false);
-			$this->set_error(mysql_error());
+			$retval = ( $this->doQuery($sql, $this->oDbHandle) ? true : false);
+			$this->setError(mysql_error());
 		}
 		return $retval;
 	}
-
+/**
+ * Alias for removeField()
+ */
+	public function field_remove($table_name, $field_name)
+	{
+		return $this->removeField($table_name, $field_name);
+	}
 /*
  * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
  * @param string $field_name: name of the field to remove
  * @return bool: true if successful, otherwise false and error will be set
  */
-	public function field_remove($table_name, $field_name)
+	public function removeField($table_name, $field_name)
 	{
 		$retval = false;
-		if( $this->field_exists($table_name, $field_name) )
-		{ // modify a existing field in a table
+		if ($this->isField($table_name, $field_name)) {
+		// modify a existing field in a table
 			$sql  = 'ALTER TABLE `'.$table_name.'` DROP `'.$field_name.'`';
-			$retval = ( $this->query($sql, $this->_db_handle) ? true : false );
+			$retval = ( $this->doQuery($sql, $this->oDbHandle) ? true : false );
 		}
 		return $retval;
 	}
-
+/**
+ * Alias for addIndex()
+ */
+    public function index_add($table_name, $index_name, $field_list, $index_type = 'KEY')
+	{
+		return $this->addIndex($table_name, $index_name, $field_list, $index_type);
+	}
 /*
  * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
  * @param string $index_name: name of the new index (empty string for PRIMARY)
@@ -364,7 +454,7 @@
  * @param string $index_type: kind of index (PRIMARY, UNIQUE, KEY, FULLTEXT)
  * @return bool: true if successful, otherwise false and error will be set
  */
-     public function index_add($table_name, $index_name, $field_list, $index_type = 'KEY')
+     public function addIndex($table_name, $index_name, $field_list, $index_type = 'KEY')
      {
         $retval = false;
         $field_list = explode(',', (str_replace(' ', '', $field_list)));
@@ -371,38 +461,54 @@
         $number_fields = sizeof($field_list);
         $field_list = '`'.implode('`,`', $field_list).'`';
         $index_name = $index_type == 'PRIMARY' ? $index_type : $index_name;
-        if( $this->index_exists($table_name, $index_name, $number_fields) ||
-            $this->index_exists($table_name, $index_name))
+        if ( $this->isIndex($table_name, $index_name, $number_fields) ||
+             $this->isIndex($table_name, $index_name))
         {
             $sql  = 'ALTER TABLE `'.$table_name.'` ';
             $sql .= 'DROP INDEX `'.$index_name.'`';
-            if( !$this->query($sql, $this->_db_handle)) { return false; }
+            if (!$this->doQuery($sql, $this->oDbHandle)) { return false; }
         }
         $sql  = 'ALTER TABLE `'.$table_name.'` ';
         $sql .= 'ADD '.$index_type.' ';
         $sql .= $index_type == 'PRIMARY' ? 'KEY ' : '`'.$index_name.'` ';
         $sql .= '( '.$field_list.' ); ';
-        if( $this->query($sql, $this->_db_handle)) { $retval = true; }
+        if ($this->doQuery($sql, $this->oDbHandle)) { $retval = true; }
         return $retval;
     }
-
+/**
+ * Alias for removeIndex()
+ */
+	public function index_remove($table_name, $index_name)
+	{
+		return $this->removeIndex($table_name, $index_name);
+	}
 /*
  * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
  * @param string $field_name: name of the field to remove
  * @return bool: true if successful, otherwise false and error will be set
  */
-	public function index_remove($table_name, $index_name)
+	public function removeIndex($table_name, $index_name)
 	{
 		$retval = false;
-		if( $this->index_exists($table_name, $index_name) )
-		{ // modify a existing field in a table
+		if ($this->isIndex($table_name, $index_name)) {
+		// modify a existing field in a table
 			$sql  = 'ALTER TABLE `'.$table_name.'` DROP INDEX `'.$index_name.'`';
-			$retval = ( $this->query($sql, $this->_db_handle) ? true : false );
+			$retval = ( $this->doQuery($sql, $this->oDbHandle) ? true : false );
 		}
 		return $retval;
 	}
-
 /**
+ * Alias for importSql()
+ */
+	public function SqlImport($sSqlDump,
+	                          $sTablePrefix = '',
+	                          $bPreserve    = true,
+	                          $sEngine      = 'MyISAM',
+	                          $sCollation   = 'utf8_unicode_ci')
+	{
+		return $this->importSql($sSqlDump, $sTablePrefix, $bPreserve, $sEngine, $sCollation);
+	}
+/**
  * Import a standard *.sql dump file
  * @param string $sSqlDump link to the sql-dumpfile
  * @param string $sTablePrefix
@@ -410,9 +516,11 @@
  * @param string   $sEngine     can be 'MyISAM' or 'InnoDB'
  * @param string   $sCollation  one of the list of available collations
  * @return boolean true if import successful
+ * @description Import a standard *.sql dump file<br />
+ *              The file can include placeholders TABLE_PREFIX, TABLE_COLLATION and TABLE_ENGINE
  */
-	public function SqlImport($sSqlDump,
-	                          $sTablePrefix = '',
+	public function importSql($sSqlDump,
+	                          $sTablePrefix = '', /* unused argument, for backward compatibility only! */
 	                          $bPreserve    = true,
 	                          $sEngine      = 'MyISAM',
 	                          $sCollation   = 'utf8_unicode_ci')
@@ -429,7 +537,7 @@
 		$aSql = file($sSqlDump);
 //		$aSql[0] = preg_replace('/^\xEF\xBB\xBF/', '', $aSql[0]);
 		$aSql[0] = preg_replace('/^[\xAA-\xFF]{3}/', '', $aSql[0]);
-		while ( sizeof($aSql) > 0 ) {
+		while (sizeof($aSql) > 0) {
 			$sSqlLine = trim(array_shift($aSql));
 			if (!preg_match('/^[-\/]+.*/', $sSqlLine)) {
 				$sql = $sql.' '.$sSqlLine;
@@ -436,9 +544,9 @@
 				if ((substr($sql,-1,1) == ';')) {
 					$sql = trim(str_replace( $aSearch, $aReplace, $sql));
 					if (!($bPreserve && preg_match('/^\s*DROP TABLE IF EXISTS/siU', $sql))) {
-						if(!mysql_query($sql, $this->_db_handle)) {
+						if (!mysql_query($sql, $this->oDbHandle)) {
 							$retval = false;
-							$this->error = mysql_error($this->_db_handle);
+							$this->error = mysql_error($this->oDbHandle);
 							unset($aSql);
 							break;
 						}
@@ -449,7 +557,6 @@
 		}
 		return $retval;
 	}
-
 /**
  * retuns the type of the engine used for requested table
  * @param string $table name of the table, including prefix
@@ -458,11 +565,11 @@
 	public function getTableEngine($table)
 	{
 		$retVal = false;
-		$mysqlVersion = mysql_get_server_info($this->_db_handle);
+		$mysqlVersion = mysql_get_server_info($this->oDbHandle);
 		$engineValue = (version_compare($mysqlVersion, '5.0') < 0) ? 'Type' : 'Engine';
-		$sql = 'SHOW TABLE STATUS FROM `' . $this->_db_name . '` LIKE \'' . $table . '\'';
-		if(($result = $this->query($sql, $this->_db_handle))) {
-			if(($row = $result->fetchRow(MYSQL_ASSOC))) {
+		$sql = 'SHOW TABLE STATUS FROM `' . $this->sDbName . '` LIKE \'' . $table . '\'';
+		if (($result = $this->doQuery($sql, $this->oDbHandle))) {
+			if (($row = $result->fetchRow(MYSQL_ASSOC))) {
 				$retVal = $row[$engineValue];
 			}
 		}
@@ -477,8 +584,8 @@
  *
  * @category     Core
  * @package      Core_database
- * @author       Werner v.d.Decken <wkl@isteam.de>
- * @copyright    Werner v.d.Decken <wkl@isteam.de>
+ * @author       Manuela v.d.Decken <manuela@isteam.de>
+ * @copyright    Manuela v.d.Decken <manuela@isteam.de>
  * @license      http://www.gnu.org/licenses/gpl.html   GPL License
  * @version      2.9.0
  * @revision     $Revision$
@@ -487,43 +594,95 @@
  */
 class WbDatabaseException extends AppException {}
 
-define('MYSQL_SEEK_FIRST', 0);
-define('MYSQL_SEEK_LAST', -1);
+/* extend global constants of mysql */
+if(!defined('MYSQL_SEEK_FIRST')) { define('MYSQL_SEEK_FIRST', 0); }
+if(!defined('MYSQL_SEEK_LAST')) { define('MYSQL_SEEK_LAST', -1); }
 
+/**
+ * mysql
+ *
+ * @category     Core
+ * @package      Core_database
+ * @author       Manuela v.d.Decken <manuela@isteam.de>
+ * @copyright    Manuela v.d.Decken <manuela@isteam.de>
+ * @license      http://www.gnu.org/licenses/gpl.html   GPL License
+ * @version      2.9.0
+ * @revision     $Revision$
+ * @lastmodified $Date$
+ * @description  MYSQL result object for requests
+ *
+ */
 class mysql {
 
 	private $result = null;
 	private $_db_handle = null;
-	// Run a query
-	function query($statement, $dbHandle) {
-		$this->_db_handle = $dbHandle;
-		$this->result = @mysql_query($statement, $this->_db_handle);
-		if($this->result === false) {
-			if(DEBUG) {
-				throw new WbDatabaseException(mysql_error($this->_db_handle));
-			}else{
+
+/**
+ * query sql statement
+ * @param  string $statement
+ * @param  object $dbHandle
+ * @return object
+ * @throws WbDatabaseException
+ */
+	function query($statement, $dbHandle)
+	{
+		$this->oDbHandle = $dbHandle;
+		$this->result = @mysql_query($statement, $this->oDbHandle);
+		if ($this->result === false) {
+			if (DEBUG) {
+				throw new WbDatabaseException(mysql_error($this->oDbHandle));
+			} else {
 				throw new WbDatabaseException('Error in SQL-Statement');
 			}
 		}
-		$this->error = mysql_error($this->_db_handle);
+		$this->error = mysql_error($this->oDbHandle);
 		return $this->result;
 	}
-
-	// Fetch num rows
-	function numRows() {
+/**
+ * numRows
+ * @return integer
+ * @description number of returned records
+ */
+	function numRows()
+	{
 		return mysql_num_rows($this->result);
 	}
-
-	// Fetch row  $typ = MYSQL_ASSOC, MYSQL_NUM, MYSQL_BOTH
-	function fetchRow($typ = MYSQL_BOTH) {
+/**
+ * fetchRow
+ * @param  int $typ MYSQL_BOTH(default) | MYSQL_ASSOC | MYSQL_NUM
+ * @return array
+ * @description get current record and increment pointer
+ */
+	function fetchRow($typ = MYSQL_BOTH)
+	{
 		return mysql_fetch_array($this->result, $typ);
 	}
-
+/**
+ * fetchObject
+ * @param  string $sClassname Name of the class to use. Is no given use stdClass
+ * @param  string $aParams    optional array of arguments for the constructor
+ * @return object
+ * @description get current record as an object and increment pointer
+ */
+	function fetchObject($sClassName = null, array $aParams = null)
+	{
+		return mysql_fetch_object($this->result, $sClassName, $aParams);
+	}
+/**
+ * rewind
+ * @return bool
+ * @description set the recordpointer to the first record || false on error
+ */
 	function rewind()
 	{
-		return $this->seekRow();
+		return $this->seekRow(MYSQL_SEEK_FIRST);
 	}
-
+/**
+ * seekRow
+ * @param int $position
+ * @return bool
+ * @description set the pointer to the given record || false on error
+ */
 	function seekRow( $position = MYSQL_SEEK_FIRST )
 	{
 		$pmax = $this->numRows() - 1;
@@ -530,10 +689,22 @@
 		$p = (($position < 0 || $position > $pmax) ? $pmax : $position);
 		return mysql_data_seek($this->result, $p);
 	}
-
-	// Get error
-	function error() {
-		if(isset($this->error)) {
+/**
+ * freeResult
+ * @return bool
+ * @description remove retult object from memeory
+ */
+	function freeResult()
+	{
+		return mysql_free_result($this->result);
+	}
+/** 
+ * Get error
+ * @return string || null if no error
+ */
+	function error()
+	{
+		if (isset($this->error)) {
 			return $this->error;
 		} else {
 			return null;
@@ -553,11 +724,9 @@
  */
 	function db_update_key_value($table, $key, $value = '')
 	{
-		global $database;
-		if( !is_array($key))
-		{
-			if( trim($key) != '' )
-			{
+		$oDb = WbDatabase::getInstance();
+		if (!is_array($key)) {
+			if (trim($key) != '') {
 				$key = array( trim($key) => trim($value) );
 			} else {
 				$key = array();
@@ -568,21 +737,19 @@
 		{
 			$index = strtolower($index);
 			$sql = 'SELECT COUNT(`setting_id`) '
-			     . 'FROM `'.TABLE_PREFIX.$table.'` '
+			     . 'FROM `'.$oDb->TablePrefix.$table.'` '
 			     . 'WHERE `name` = \''.$index.'\' ';
-			if($database->get_one($sql))
-			{
+			if ($oDb->getOne($sql)) {
 				$sql = 'UPDATE ';
 				$sql_where = 'WHERE `name` = \''.$index.'\'';
-			}else {
+			} else {
 				$sql = 'INSERT INTO ';
 				$sql_where = '';
 			}
-			$sql .= '`'.TABLE_PREFIX.$table.'` ';
+			$sql .= '`'.$oDb->TablePrefix.$table.'` ';
 			$sql .= 'SET `name` = \''.$index.'\', ';
 			$sql .= '`value` = \''.$val.'\' '.$sql_where;
-			if( !$database->query($sql) )
-			{
+			if (!$oDb->doQuery($sql)) {
 				$retval = false;
 			}
 		}
