123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class CI_DB_pdo_firebird_forge extends CI_DB_pdo_forge {
-
- protected $_rename_table = FALSE;
-
- protected $_unsigned = array(
- 'SMALLINT' => 'INTEGER',
- 'INTEGER' => 'INT64',
- 'FLOAT' => 'DOUBLE PRECISION'
- );
-
- protected $_null = 'NULL';
-
-
- public function create_database($db_name)
- {
-
-
- empty($this->db->hostname) OR $db_name = $this->hostname.':'.$db_name;
- return parent::create_database('"'.$db_name.'"');
- }
-
-
- public function drop_database($db_name)
- {
- if ( ! ibase_drop_db($this->conn_id))
- {
- return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
- }
- elseif ( ! empty($this->db->data_cache['db_names']))
- {
- $key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE);
- if ($key !== FALSE)
- {
- unset($this->db->data_cache['db_names'][$key]);
- }
- }
- return TRUE;
- }
-
-
- protected function _alter_table($alter_type, $table, $field)
- {
- if (in_array($alter_type, array('DROP', 'ADD'), TRUE))
- {
- return parent::_alter_table($alter_type, $table, $field);
- }
- $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
- $sqls = array();
- for ($i = 0, $c = count($field); $i < $c; $i++)
- {
- if ($field[$i]['_literal'] !== FALSE)
- {
- return FALSE;
- }
- if (isset($field[$i]['type']))
- {
- $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
- .' TYPE '.$field[$i]['type'].$field[$i]['length'];
- }
- if ( ! empty($field[$i]['default']))
- {
- $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
- .' SET '.$field[$i]['default'];
- }
- if (isset($field[$i]['null']))
- {
- $sqls[] = 'UPDATE "RDB$RELATION_FIELDS" SET "RDB$NULL_FLAG" = '
- .($field[$i]['null'] === TRUE ? 'NULL' : '1')
- .' WHERE "RDB$FIELD_NAME" = '.$this->db->escape($field[$i]['name'])
- .' AND "RDB$RELATION_NAME" = '.$this->db->escape($table);
- }
- if ( ! empty($field[$i]['new_name']))
- {
- $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
- .' TO '.$this->db->escape_identifiers($field[$i]['new_name']);
- }
- }
- return $sqls;
- }
-
-
- protected function _process_column($field)
- {
- return $this->db->escape_identifiers($field['name'])
- .' '.$field['type'].$field['length']
- .$field['null']
- .$field['unique']
- .$field['default'];
- }
-
-
- protected function _attr_type(&$attributes)
- {
- switch (strtoupper($attributes['TYPE']))
- {
- case 'TINYINT':
- $attributes['TYPE'] = 'SMALLINT';
- $attributes['UNSIGNED'] = FALSE;
- return;
- case 'MEDIUMINT':
- $attributes['TYPE'] = 'INTEGER';
- $attributes['UNSIGNED'] = FALSE;
- return;
- case 'INT':
- $attributes['TYPE'] = 'INTEGER';
- return;
- case 'BIGINT':
- $attributes['TYPE'] = 'INT64';
- return;
- default: return;
- }
- }
-
-
- protected function _attr_auto_increment(&$attributes, &$field)
- {
-
- }
- }
|