diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-11-12 11:51:14 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-11-12 11:51:14 +0100 |
commit | b67277b8063b0e6aab051ce269194255ef83e808 (patch) | |
tree | f0ce631b9ee3134de2cf009e4d5f02401f31aaac /system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php | |
parent | b0a97c100f5e7edc5e21ec7d07f768cd3b5618da (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/drivers/pdo/subdrivers/pdo_mysql_forge.php')
-rw-r--r-- | system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php index 24c470a83..866b6fb21 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php +++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php @@ -1,4 +1,4 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php /** * CodeIgniter * @@ -162,6 +162,14 @@ class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge { */ protected function _process_column($field) { + $extra_clause = isset($field['after']) + ? ' AFTER '.$this->db->escape_identifiers($field['after']) : ''; + + if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE) + { + $extra_clause = ' FIRST'; + } + return $this->db->escape_identifiers($field['name']) .(empty($field['new_name']) ? '' : $this->db->escape_identifiers($field['new_name'])) .' '.$field['type'].$field['length'] @@ -169,7 +177,8 @@ class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge { .$field['null'] .$field['default'] .$field['auto_increment'] - .$field['unique']; + .$field['unique'] + .$extra_clause; } // -------------------------------------------------------------------- |