summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/pdo/pdo_forge.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-02-10 13:33:28 +0100
committerAndrey Andreev <narf@bofh.bg>2012-02-10 13:33:28 +0100
commit6b7368f61761d8fd177ab752c6bea829f0ca2ea5 (patch)
treebc801f54de79a714f80ef2a38febe33cb7af9374 /system/database/drivers/pdo/pdo_forge.php
parent8d7fffc9f0aa49d7bf306060f0676a7b28b7c808 (diff)
parent16af6afe991381360439135ddb0735dab1280fed (diff)
Merge remote-tracking branch 'upstream/develop' into develop-image-lib
Diffstat (limited to 'system/database/drivers/pdo/pdo_forge.php')
-rw-r--r--system/database/drivers/pdo/pdo_forge.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php
index 076415928..478b2dbfb 100644
--- a/system/database/drivers/pdo/pdo_forge.php
+++ b/system/database/drivers/pdo/pdo_forge.php
@@ -96,7 +96,7 @@ class CI_DB_pdo_forge extends CI_DB_forge {
$sql .= 'IF NOT EXISTS ';
}
- $sql .= $this->db->_escape_identifiers($table)." (";
+ $sql .= '`'.$this->db->_escape_identifiers($table).'` (';
$current_field_count = 0;
foreach ($fields as $field=>$attributes)
@@ -111,6 +111,7 @@ class CI_DB_pdo_forge extends CI_DB_forge {
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
+ $numeric = array('SERIAL', 'INTEGER');
$sql .= "\n\t".$this->db->_protect_identifiers($field);
@@ -118,7 +119,11 @@ class CI_DB_pdo_forge extends CI_DB_forge {
if (array_key_exists('CONSTRAINT', $attributes))
{
- $sql .= '('.$attributes['CONSTRAINT'].')';
+ // Exception for Postgre numeric which not too happy with constraint within those type
+ if ( ! ($this->db->pdodriver == 'pgsql' && in_array($attributes['TYPE'], $numeric)))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
@@ -219,7 +224,7 @@ class CI_DB_pdo_forge extends CI_DB_forge {
*/
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+ $sql = 'ALTER TABLE `'.$this->db->_protect_identifiers($table)."` $alter_type ".$this->db->_protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
@@ -271,7 +276,6 @@ class CI_DB_pdo_forge extends CI_DB_forge {
return $sql;
}
-
}
/* End of file pdo_forge.php */