summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mysqli
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-05-29 19:52:11 +0200
committerDerek Jones <derek.jones@ellislab.com>2008-05-29 19:52:11 +0200
commitbd4400988922b2560975a80498404d7ecd000c0b (patch)
tree2c8630cd43f1a16700c53363578191de342fb3d4 /system/database/drivers/mysqli
parent9e11220c2b780ca3320deae7e91a272b84c88533 (diff)
made MySQL/MySQLi forge use explicitly named KEYs, added ability to specify multi-column non-primary keys in table creation
Diffstat (limited to 'system/database/drivers/mysqli')
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index f767acbea..da79bc6ac 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -153,16 +153,27 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
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) . ")";
}
}