1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5
* An open source application development framework for PHP 5.1.6 or newer
8
* @author ExpressionEngine Dev Team
9
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
10
* @license http://codeigniter.com/user_guide/license.html
11
* @link http://codeigniter.com
16
// ------------------------------------------------------------------------
22
* @author ExpressionEngine Dev Team
23
* @link http://codeigniter.com/user_guide/database/
25
class CI_DB_oci8_forge extends CI_DB_forge {
31
* @param string the database name
34
function _create_database($name)
39
// --------------------------------------------------------------------
45
* @param string the database name
48
function _drop_database($name)
53
// --------------------------------------------------------------------
59
* @param string the table name
60
* @param array the fields
61
* @param mixed primary key(s)
63
* @param boolean should 'IF NOT EXISTS' be added to the SQL
66
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
68
$sql = 'CREATE TABLE ';
70
if ($if_not_exists === TRUE)
72
$sql .= 'IF NOT EXISTS ';
75
$sql .= $this->db->_escape_identifiers($table)." (";
76
$current_field_count = 0;
78
foreach ($fields as $field=>$attributes)
80
// Numeric field names aren't allowed in databases, so if the key is
81
// numeric, we know it was assigned by PHP and the developer manually
82
// entered the field information, so we'll simply add it to the list
83
if (is_numeric($field))
85
$sql .= "\n\t$attributes";
89
$attributes = array_change_key_case($attributes, CASE_UPPER);
91
$sql .= "\n\t".$this->db->_protect_identifiers($field);
93
$sql .= ' '.$attributes['TYPE'];
95
if (array_key_exists('CONSTRAINT', $attributes))
97
$sql .= '('.$attributes['CONSTRAINT'].')';
100
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
105
if (array_key_exists('DEFAULT', $attributes))
107
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
110
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
119
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
121
$sql .= ' AUTO_INCREMENT';
125
// don't add a comma on the end of the last field
126
if (++$current_field_count < count($fields))
132
if (count($primary_keys) > 0)
134
$primary_keys = $this->db->_protect_identifiers($primary_keys);
135
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
138
if (is_array($keys) && count($keys) > 0)
140
foreach ($keys as $key)
144
$key = $this->db->_protect_identifiers($key);
148
$key = array($this->db->_protect_identifiers($key));
151
$sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")";
160
// --------------------------------------------------------------------
168
function _drop_table($table)
173
// --------------------------------------------------------------------
178
* Generates a platform-specific query so that a table can be altered
179
* Called by add_column(), drop_column(), and column_alter(),
182
* @param string the ALTER type (ADD, DROP, CHANGE)
183
* @param string the column name
184
* @param string the table name
185
* @param string the column definition
186
* @param string the default value
187
* @param boolean should 'NOT NULL' be added
188
* @param string the field after which we should add the new field
191
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
193
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
195
// DROP has everything it needs now.
196
if ($alter_type == 'DROP')
201
$sql .= " $column_definition";
203
if ($default_value != '')
205
$sql .= " DEFAULT \"$default_value\"";
217
if ($after_field != '')
219
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
226
// --------------------------------------------------------------------
231
* Generates a platform-specific query so that a table can be renamed
234
* @param string the old table name
235
* @param string the new table name
238
function _rename_table($table_name, $new_table_name)
240
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
247
/* End of file oci8_forge.php */
248
/* Location: ./system/database/drivers/oci8/oci8_forge.php */
b'\\ No newline at end of file'