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).
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 7c9c03e..2104601 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -532,11 +532,13 @@
/**
* 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 @@
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]));
}