Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 1361)
+++ branches/2.8.x/CHANGELOG	(revision 1362)
@@ -11,6 +11,8 @@
 ! = Update/Change
 
 ------------------------------------- 2.8.2 -------------------------------------
+29 Dec-2010 Build 1362 Dietmar Woellbrink (Luisehahne)
+! additional functions added in class.database
 28 Dec-2010 Build 1361 Dietmar Woellbrink (Luisehahne)
 ! sync languages files with 2.9.0.dev
 ! unzip addons now overwrite newer files
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 1361)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 1362)
@@ -52,6 +52,6 @@
 
 // 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.2.RC2');
-if(!defined('REVISION')) define('REVISION', '1361');
+if(!defined('REVISION')) define('REVISION', '1362');
 
 ?>
\ No newline at end of file
Index: branches/2.8.x/wb/framework/class.database.php
===================================================================
--- branches/2.8.x/wb/framework/class.database.php	(revision 1361)
+++ branches/2.8.x/wb/framework/class.database.php	(revision 1362)
@@ -1,30 +1,23 @@
 <?php
+/**
+ *
+ * @category        framework
+ * @package         database
+ * @author          WebsiteBaker Project
+ * @copyright       2004-2009, Ryan Djurovich
+ * @copyright       2009-2011, Website Baker Org. e.V.
+ * @link            http://www.websitebaker2.org/
+ * @license         http://www.gnu.org/licenses/gpl.html
+ * @platform        WebsiteBaker 2.8.x
+ * @requirements    PHP 5.2.2 and higher
+ * @version         $Id$
+ * @filesource      $HeadURL:  $
+ * @lastmodified    $Date:  $
+ *
+ */
 
-// $Id$
-
 /*
 
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2009, Ryan Djurovich
-
- Website Baker is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Website Baker is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Website Baker; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-*/
-
-/*
-
 Database class
 
 This class will be used to interface between the database
@@ -45,7 +38,16 @@
 define('DATABASE_CLASS_LOADED', true);
 
 class database {
-	
+
+	private $db_handle  = null; // readonly from outside
+
+	private $connected  = false;
+
+	private $error      = '';
+	private $error_type = '';
+	private $message    = array();
+
+
 	// Set DB_URL
 	function database($url = '') {
 		// Connect to database
@@ -94,10 +96,11 @@
 			return $mysql;
 		}
 	}
-	
+
 	// Gets the first column of the first row
-	function get_one($statement) {
-		$fetch_row = mysql_fetch_row(mysql_query($statement));
+	function get_one( $statement )
+	{
+		$fetch_row = mysql_fetch_array(mysql_query($statement) );
 		$result = $fetch_row[0];
 		$this->set_error(mysql_error());
 		if(mysql_error()) {
@@ -127,9 +130,162 @@
 	function get_error() {
 		return $this->error;
 	}
-	
-}
 
+/*
+ * default Getter
+ */
+	public function __get($var_name)
+	{
+		if($var_name == 'db_handle')
+		{
+			return $this->db_handle;
+		}
+		return null;
+	}
+
+/*
+ * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
+ * @param string $field_name: name of the field to seek for
+ * @return bool: true if field exists
+ */
+	public function field_exists($table_name, $field_name)
+	{
+		$sql = 'DESCRIBE `'.$table_name.'` `'.$field_name.'` ';
+		$query = $this->query($sql);
+		return ($query->numRows() != 0);
+	}
+
+/*
+ * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
+ * @param string $index_name: name of the index to seek for
+ * @return bool: true if field exists
+ */
+	public function index_exists($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)) )
+		{
+			while(($rec_key = $res_keys->fetchRow()))
+			{
+				if( $rec_key['Key_name'] == $index_name )
+				{
+					$keys++;
+				}
+			}
+
+		}
+		if( $number_fields == 0 )
+		{
+			return ($keys != $number_fields);
+		}else
+		{
+			return ($keys == $number_fields);
+		}
+	}
+/*
+ * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
+ * @param string $field_name: name of the field to add
+ * @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_add($table_name, $field_name, $description)
+	{
+		if( !$this->field_exists($field_name, $table_name) )
+		{ // add new field into a table
+			$sql = 'ALTER TABLE `'.$table_name.'` ADD '.$field_name.' '.$description.' ';
+			$query = $this->query($sql);
+			$this->set_error(mysql_error());
+			if( !$this->is_error() )
+			{
+				return ( $this->field_exists($field_name, $table_name) ) ? true : false;
+			}
+		}else
+		{
+			$this->set_error('field \''.$field_name.'\' already exists');
+		}
+		return false;
+	}
+
+/*
+ * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
+ * @param string $field_name: name of the field to add
+ * @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)
+	{
+		$retval = false;
+		if( $this->field_exists($field_name, $table_name) )
+		{ // modify a existing field in a table
+			$sql  = 'ALTER TABLE `'.$table_name.'` DROP `'.$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)
+	{
+		$retval = false;
+		if( $this->field_exists($field_name, $table_name) )
+		{ // modify a existing field in a table
+			$sql  = 'ALTER TABLE `'.$table_name.'` DROP `'.$field_name.'`';
+			$retval = ( $this->query($sql) ? true : false );
+		}
+		return $retval;
+	}
+
+/*
+ * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
+ * @param string $index_name: name of the new index
+ * @param string $field_list: comma seperated list of fields for this index
+ * @param string $index_type: kind of index (UNIQUE, PRIMARY, '')
+ * @return bool: true if successful, otherwise false and error will be set
+ */
+	public function index_add($table_name, $index_name, $field_list, $index_type = '')
+	{
+		$retval = false;
+		$field_list = str_replace(' ', '', $field_list);
+		$field_list = explode(',', $field_list);
+		$number_fields = sizeof($field_list);
+		$field_list = '`'.implode('`,`', $field_list).'`';
+		if( $this->index_exists($table_name, $index_name, $number_fields) ||
+		    $this->index_exists($table_name, $index_name))
+		{
+			$sql  = 'ALTER TABLE `'.$table_name.'` ';
+			$sql .= 'DROP INDEX `'.$index_name.'`';
+			if( $this->query($sql))
+			{
+				$sql  = 'ALTER TABLE `'.$table_name.'` ';
+				$sql .= 'ADD '.$index_type.' `'.$index_name.'` ( '.$field_list.' ); ';
+				if( $this->query($sql)) { $retval = true; }
+			}
+		}
+		return $retval;
+	}
+
+/*
+ * @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)
+	{
+		$retval = false;
+		if( $this->index_exists($table_name, $index_name) )
+		{ // modify a existing field in a table
+			$sql  = 'ALTER TABLE `'.$table_name.'` DROP INDEX `'.$index_name.'`';
+			$retval = ( $this->query($sql) ? true : false );
+		}
+		return $retval;
+	}
+
+} /// end of class database
+
 class mysql {
 
 	// Run a query
