From 48a2baf0e288accd206f5da5031d29076e130792 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:09:54 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/database --- system/database/drivers/oci8/oci8_forge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database/drivers/oci8/oci8_forge.php') diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index bd265b6e0..837e7eaad 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -141,9 +141,9 @@ class CI_DB_oci8_forge extends CI_DB_forge { } return $sql.' '.$column_definition - .($default_value != '' ? ' DEFAULT "'.$default_value.'"' : '') + .($default_value !== '' ? ' DEFAULT "'.$default_value.'"' : '') .($null === NULL ? ' NULL' : ' NOT NULL') - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } -- cgit v1.2.3-24-g4f1b From 5ef194df98294d5427c0e7582ca88b1fc06e1d72 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 8 Jun 2012 01:12:54 +0300 Subject: Resolve formatting differences between DB forge drivers --- system/database/drivers/oci8/oci8_forge.php | 38 +++++++++++++++++------------ 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'system/database/drivers/oci8/oci8_forge.php') diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 837e7eaad..4fd3dc4a5 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -73,11 +73,22 @@ class CI_DB_oci8_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->protect_identifiers($field).' '.$attributes['TYPE'] - .((isset($attributes['UNSINGED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') - .(isset($attributes['DEFAULT']) ? " DEFAULT '".$attributes['DEFAULT']."'" : '') - .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? '' : ' NOT NULL') - .(isset($attributes['CONSTRAINT']) ? ' CONSTRAINT '.$attributes['CONSTRAINT'] : ''); + $sql .= "\n\t".$this->db->escape_identifiers($field).' '.$attributes['TYPE']; + + if (isset($attributes['UNSINGED']) && $attributes['UNSIGNED'] === TRUE) + { + $sql .= ' UNSIGNED'; + } + + if (isset($attributes['DEFAULT'])) + { + $sql .= " DEFAULT '".$attributes['DEFAULT']."'"; + } + + $sql .= (isset($attributes['NULL']) && $attributes['NULL'] === TRUE) + ? '' : ' NOT NULL'; + + empty($attributes['CONSTRAINT']) OR ' CONSTRAINT '.$attributes['CONSTRAINT']; } // don't add a comma on the end of the last field @@ -89,7 +100,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->protect_identifiers($primary_keys); + $primary_keys = $this->db->escape_identifiers($primary_keys); $sql .= ",\n\tCONSTRAINT ".$table.' PRIMARY KEY ('.implode(', ', $primary_keys).')'; } @@ -97,14 +108,9 @@ class CI_DB_oci8_forge extends CI_DB_forge { { foreach ($keys as $key) { - if (is_array($key)) - { - $key = $this->db->protect_identifiers($key); - } - else - { - $key = array($this->db->protect_identifiers($key)); - } + $key = is_array($key) + ? $this->db->escape_identifiers($key) + : array($this->db->escape_identifiers($key)); $sql .= ",\n\tUNIQUE COLUMNS (".implode(', ', $key).')'; } @@ -132,7 +138,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { */ protected 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->escape_identifiers($table).' '.$alter_type.' '.$this->db->escape_identifiers($column_name); // DROP has everything it needs now. if ($alter_type === 'DROP') @@ -143,7 +149,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { return $sql.' '.$column_definition .($default_value !== '' ? ' DEFAULT "'.$default_value.'"' : '') .($null === NULL ? ' NULL' : ' NOT NULL') - .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->escape_identifiers($after_field) : ''); } -- cgit v1.2.3-24-g4f1b From caa04f15096590261093dff2a8b59f266a1dcaf5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 8 Jun 2012 01:39:20 +0300 Subject: Revert back some escape_identifiers() to proect_identifiers() as the first one can't handle arrays --- system/database/drivers/oci8/oci8_forge.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'system/database/drivers/oci8/oci8_forge.php') diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 4fd3dc4a5..be093750b 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -100,8 +100,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->escape_identifiers($primary_keys); - $sql .= ",\n\tCONSTRAINT ".$table.' PRIMARY KEY ('.implode(', ', $primary_keys).')'; + $sql .= ",\n\tCONSTRAINT ".$table.' PRIMARY KEY ('.implode(', ', $this->db->protect_identifiers($primary_keys)).')'; } if (is_array($keys) && count($keys) > 0) @@ -109,7 +108,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { foreach ($keys as $key) { $key = is_array($key) - ? $this->db->escape_identifiers($key) + ? $this->db->protect_identifiers($key) : array($this->db->escape_identifiers($key)); $sql .= ",\n\tUNIQUE COLUMNS (".implode(', ', $key).')'; -- cgit v1.2.3-24-g4f1b From 9637b40ca9e9ac1cdce2b895d3db09848a6eef76 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 8 Jun 2012 15:39:24 +0300 Subject: escape_identifiers() to accept arrays as well --- system/database/drivers/oci8/oci8_forge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database/drivers/oci8/oci8_forge.php') diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index be093750b..92e8c02ed 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -100,7 +100,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $sql .= ",\n\tCONSTRAINT ".$table.' PRIMARY KEY ('.implode(', ', $this->db->protect_identifiers($primary_keys)).')'; + $sql .= ",\n\tCONSTRAINT ".$table.' PRIMARY KEY ('.implode(', ', $this->db->escape_identifiers($primary_keys)).')'; } if (is_array($keys) && count($keys) > 0) @@ -108,7 +108,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { foreach ($keys as $key) { $key = is_array($key) - ? $this->db->protect_identifiers($key) + ? $this->db->escape_identifiers($key) : array($this->db->escape_identifiers($key)); $sql .= ",\n\tUNIQUE COLUMNS (".implode(', ', $key).')'; -- cgit v1.2.3-24-g4f1b