Add support for optional table attributes to CI_DB_forge::create_table()

Supersedes PRs #989, #2776
Related issue: #41
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index e251c0e..3b3cbde 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -82,16 +82,34 @@
 	// --------------------------------------------------------------------
 
 	/**
-	 * Class constructor
+	 * CREATE TABLE attributes
 	 *
-	 * @param	object	&$db	Database object
-	 * @return	void
+	 * @param	array	$attributes	Associative array of table attributes
+	 * @return	string
 	 */
-	public function __construct(&$db)
+	protected function _create_table_attr($attributes)
 	{
-		parent::__construct($db);
+		$sql = '';
 
-		$this->_create_table .= ' DEFAULT CHARSET '.$this->db->char_set.' COLLATE '.$this->db->dbcollat;
+		foreach (array_keys($attributes) as $key)
+		{
+			if (is_string($key))
+			{
+				$sql .= ' '.strtoupper($key).' = '.$attributes[$key];
+			}
+		}
+
+		if ( ! empty($this->db->char_set) && ! strpos($sql, 'CHARACTER SET') && ! strpos($sql, 'CHARSET'))
+		{
+			$sql .= ' DEFAULT CHARACTER SET = '.$this->db->char_set;
+		}
+
+		if ( ! empty($this->db->dbcollat) && ! strpos($sql, 'COLLATE'))
+		{
+			$sql .= ' COLLATE = '.$this->db->dbcollat;
+		}
+
+		return $sql;
 	}
 
 	// --------------------------------------------------------------------