made MySQL/MySQLi forge use explicitly named KEYs, added ability to specify multi-column non-primary keys in table creation
diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php
index ddd1bb6..6995d34 100644
--- a/system/database/drivers/mssql/mssql_forge.php
+++ b/system/database/drivers/mssql/mssql_forge.php
@@ -147,16 +147,24 @@
 			$primary_keys = $this->db->_protect_identifiers($primary_keys);

 			$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";

 		}

-

+		

 		if (is_array($keys) && count($keys) > 0)

 		{

-			$keys = $this->db->_protect_identifiers($keys);

 			foreach ($keys as $key)

 			{

-				$sql .= ",\n\tFOREIGN KEY ($key)";

+				if (is_array($key))

+				{

+					$key = $this->db->_protect_identifiers($key);	

+				}

+				else

+				{

+					$key = array($this->db->_protect_identifiers($key));

+				}

+				

+				$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";

 			}

 		}

-

+		

 		$sql .= "\n)";

 

 		return $sql;

diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index a631e43..28143a0 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -153,16 +153,27 @@
 

 		if (count($primary_keys) > 0)

 		{

+			$key_name = $this->db->_protect_identifiers(implode('_', $primary_keys));

 			$primary_keys = $this->db->_protect_identifiers($primary_keys);

-			$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";

+			$sql .= ",\n\tPRIMARY KEY ".$key_name." (" . implode(', ', $primary_keys) . ")";

 		}

 

 		if (is_array($keys) && count($keys) > 0)

 		{

-			$keys = $this->db->_protect_identifiers($keys);

 			foreach ($keys as $key)

 			{

-				$sql .= ",\n\tKEY ($key)";

+				if (is_array($key))

+				{

+					$key_name = $this->db->_protect_identifiers(implode('_', $key));

+					$key = $this->db->_protect_identifiers($key);	

+				}

+				else

+				{

+					$key_name = $this->db->_protect_identifiers($key);

+					$key = array($key_name);

+				}

+				

+				$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";

 			}

 		}

 

diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index f767acb..da79bc6 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -153,16 +153,27 @@
 

 		if (count($primary_keys) > 0)

 		{

+			$key_name = $this->db->_protect_identifiers(implode('_', $primary_keys));

 			$primary_keys = $this->db->_protect_identifiers($primary_keys);

-			$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";

+			$sql .= ",\n\tPRIMARY KEY ".$key_name." (" . implode(', ', $primary_keys) . ")";

 		}

 

 		if (is_array($keys) && count($keys) > 0)

 		{

-			$keys = $this->db->_protect_identifiers($keys);

 			foreach ($keys as $key)

 			{

-				$sql .= ",\n\tKEY ($key)";

+				if (is_array($key))

+				{

+					$key_name = $this->db->_protect_identifiers(implode('_', $key));

+					$key = $this->db->_protect_identifiers($key);	

+				}

+				else

+				{

+					$key_name = $this->db->_protect_identifiers($key);

+					$key = array($key_name);

+				}

+				

+				$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";

 			}

 		}

 

diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php
index 9f3fac5..6266c75 100644
--- a/system/database/drivers/oci8/oci8_forge.php
+++ b/system/database/drivers/oci8/oci8_forge.php
@@ -135,10 +135,21 @@
 			$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";

 		}

 

-		if (count($keys) > 0)

+		if (is_array($keys) && count($keys) > 0)

 		{

-			$keys = $this->db->_protect_identifiers($keys);

-			$sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $keys) . ")";

+			foreach ($keys as $key)

+			{

+				if (is_array($key))

+				{

+					$key = $this->db->_protect_identifiers($key);	

+				}

+				else

+				{

+					$key = array($this->db->_protect_identifiers($key));

+				}

+				

+				$sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")";

+			}

 		}

 		

 		$sql .= "\n)";

diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
index 60df616..10924ab 100644
--- a/system/database/drivers/odbc/odbc_forge.php
+++ b/system/database/drivers/odbc/odbc_forge.php
@@ -146,16 +146,24 @@
 			$primary_keys = $this->db->_protect_identifiers($primary_keys);

 			$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";

 		}

-

+		

 		if (is_array($keys) && count($keys) > 0)

 		{

-			$keys = $this->db->_protect_identifiers($keys);

 			foreach ($keys as $key)

 			{

-				$sql .= ",\n\tFOREIGN KEY ($key)";

+				if (is_array($key))

+				{

+					$key = $this->db->_protect_identifiers($key);	

+				}

+				else

+				{

+					$key = array($this->db->_protect_identifiers($key));

+				}

+				

+				$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";

 			}

 		}

-

+		

 		$sql .= "\n)";

 

 		return $sql;

diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index f8dfca8..ef57834 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -134,13 +134,21 @@
 			$primary_keys = $this->db->_protect_identifiers($primary_keys);

 			$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";

 		}

-

+		

 		if (is_array($keys) && count($keys) > 0)

 		{

-			$keys = $this->db->_protect_identifiers($keys);

 			foreach ($keys as $key)

 			{

-				$sql .= ",\n\tFOREIGN KEY ($key)";

+				if (is_array($key))

+				{

+					$key = $this->db->_protect_identifiers($key);	

+				}

+				else

+				{

+					$key = array($this->db->_protect_identifiers($key));

+				}

+				

+				$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";

 			}

 		}

 

diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
index 25c74a7..a6866c8 100644
--- a/system/database/drivers/sqlite/sqlite_forge.php
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -144,13 +144,24 @@
 			$primary_keys = $this->db->_protect_identifiers($primary_keys);

 			$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";

 		}

-

-		if (count($keys) > 0)

+		

+		if (is_array($keys) && count($keys) > 0)

 		{

-			$keys = $this->db->_protect_identifiers($keys);

-			$sql .= ",\n\tUNIQUE (" . implode(', ', $keys) . ")";

+			foreach ($keys as $key)

+			{

+				if (is_array($key))

+				{

+					$key = $this->db->_protect_identifiers($key);	

+				}

+				else

+				{

+					$key = array($this->db->_protect_identifiers($key));

+				}

+				

+				$sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")";

+			}

 		}

-

+		

 		$sql .= "\n)";

 

 		return $sql;

diff --git a/system/plugins/captcha_pi.php b/system/plugins/captcha_pi.php
index df95788..baa0a8d 100644
--- a/system/plugins/captcha_pi.php
+++ b/system/plugins/captcha_pi.php
@@ -92,8 +92,8 @@
 	 captcha_time int(10) unsigned NOT NULL,

 	 ip_address varchar(16) default '0' NOT NULL,

 	 word varchar(20) NOT NULL,

-	 PRIMARY KEY (captcha_id),

-	 KEY (word)

+	 PRIMARY KEY `captcha_id` (`captcha_id`),

+	 KEY `word` (`word`)

 	)

 

 

diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 9e39cb4..b59b9ef 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -63,6 +63,8 @@
 <ul>

 	<li>Database

 		<ul>

+			<li>Modified MySQL/MySQLi Forge class to give explicit names to keys</li>

+			<li>Added ability to set multiple column non-primary keys to the <a href="database/forge.html">Forge class</a></li>

 			<li>Added ability to set additional database config values in <a href="database/connecting.html">DSN connections</a> via the query string.</li>

 			</ul>

 	</li>

diff --git a/user_guide/database/forge.html b/user_guide/database/forge.html
index f9363f4..f679a4f 100644
--- a/user_guide/database/forge.html
+++ b/user_guide/database/forge.html
@@ -164,11 +164,19 @@
     // gives id INT(9) NOT NULL AUTO_INCREMENT</code></p>

 <h2><a name="add_key" id="add_key"></a>Adding Keys</h2>

 <p>Generally speaking, you'll want your table to have Keys. This is accomplished with <dfn>$this-&gt;dbforge-&gt;add_key('field')</dfn>. An optional second parameter set to TRUE will make it a primary key. Note that <dfn>add_key()</dfn> must be followed by a call to <dfn>create_table()</dfn>.</p>

+<p>Multiple column non-primary keys must be sent as an array.  Sample output below is for MySQL.</p>

 <p><code>$this-&gt;dbforge-&gt;add_key('blog_id', TRUE);<br />

-    // gives PRIMARY KEY (blog_id)<br />

+    // gives PRIMARY KEY `blog_id` (`blog_id`)<br />

     <br />

+    $this-&gt;dbforge-&gt;add_key('blog_id', TRUE);<br />

+    $this-&gt;dbforge-&gt;add_key('site_id', TRUE);<br />

+    // gives PRIMARY KEY `blog_id_site_id` (`blog_id`, `site_id`)<br />

+	<br />

     $this-&gt;dbforge-&gt;add_key('blog_name');<br />

-    // gives KEY (blog_name)</code></p>

+    // gives KEY `blog_name` (`blog_name`)<br />

+    <br />

+    $this-&gt;dbforge-&gt;add_key(array('blog_name', 'blog_label'));<br />

+    // gives KEY `blog_name_blog_label` (`blog_name`, `blog_label`)</code></p>

 <h2><a name="create_table" id="create_table"></a>Creating a table</h2>

 <p>After fields and keys have been declared, you can create a new table with</p>

 <p><code>$this-&gt;dbforge-&gt;create_table('table_name');<br />

diff --git a/user_guide/libraries/trackback.html b/user_guide/libraries/trackback.html
index f86ccca..4f60f5a 100644
--- a/user_guide/libraries/trackback.html
+++ b/user_guide/libraries/trackback.html
@@ -152,8 +152,8 @@
  blog_name varchar(100) NOT NULL,

  tb_date int(10) NOT NULL,

  ip_address varchar(16) NOT NULL,

- PRIMARY KEY (tb_id),

- KEY (entry_id)

+ PRIMARY KEY `tb_id` (`tb_id`),

+ KEY `entry_id` (`entry_id`)

 );</textarea>