summaryrefslogtreecommitdiffstats
path: root/system/database/DB_forge.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-11-12 11:51:14 +0100
committerAndrey Andreev <narf@bofh.bg>2012-11-12 11:51:14 +0100
commitb67277b8063b0e6aab051ce269194255ef83e808 (patch)
treef0ce631b9ee3134de2cf009e4d5f02401f31aaac /system/database/DB_forge.php
parentb0a97c100f5e7edc5e21ec7d07f768cd3b5618da (diff)
Bring back the AFTER clause for DB Forge add_column()
(it was temporarily removed due to multiple inconsistencies with other drivers) This commit also fixes issue #1988. Also added support for the FIRST clause (again, MySQL and CUBRID only).
Diffstat (limited to 'system/database/DB_forge.php')
-rw-r--r--system/database/DB_forge.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 7c9c03e24..21046012a 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -532,11 +532,13 @@ abstract class CI_DB_forge {
/**
* Column Add
*
+ * @todo Remove deprecated $_after option in 3.1+
* @param string $table Table name
* @param array $field Column definition
+ * @param string $_after Column for AFTER clause (deprecated)
* @return bool
*/
- public function add_column($table = '', $field = array())
+ public function add_column($table = '', $field = array(), $_after = NULL)
{
if ($table === '')
{
@@ -551,6 +553,12 @@ abstract class CI_DB_forge {
foreach (array_keys($field) as $k)
{
+ // Backwards-compatibility work-around for MySQL/CUBRID AFTER clause (remove in 3.1+)
+ if ($_after !== NULL && is_array($field[$k]) && ! isset($field[$k]['after']))
+ {
+ $field[$k]['after'] = $_after;
+ }
+
$this->add_field(array($k => $field[$k]));
}