123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class CI_DB_sqlite3_forge extends CI_DB_forge {
-
- protected $_unsigned = FALSE;
-
- protected $_null = 'NULL';
-
-
- public function __construct(&$db)
- {
- parent::__construct($db);
- if (version_compare($this->db->version(), '3.3', '<'))
- {
- $this->_create_table_if = FALSE;
- $this->_drop_table_if = FALSE;
- }
- }
-
-
- public function create_database($db_name)
- {
-
-
- return TRUE;
- }
-
-
- public function drop_database($db_name)
- {
-
- if (file_exists($this->db->database))
- {
-
- $this->db->close();
- if ( ! @unlink($this->db->database))
- {
- 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;
- }
- return $this->db->db_debug ? $this->db->display_error('db_unable_to_drop') : FALSE;
- }
-
-
- protected function _alter_table($alter_type, $table, $field)
- {
- if ($alter_type === 'DROP' OR $alter_type === 'CHANGE')
- {
-
-
-
-
-
-
-
-
-
- return FALSE;
- }
- return parent::_alter_table($alter_type, $table, $field);
- }
-
-
- protected function _process_column($field)
- {
- return $this->db->escape_identifiers($field['name'])
- .' '.$field['type']
- .$field['auto_increment']
- .$field['null']
- .$field['unique']
- .$field['default'];
- }
-
-
- protected function _attr_type(&$attributes)
- {
- switch (strtoupper($attributes['TYPE']))
- {
- case 'ENUM':
- case 'SET':
- $attributes['TYPE'] = 'TEXT';
- return;
- default: return;
- }
- }
-
-
- protected function _attr_auto_increment(&$attributes, &$field)
- {
- if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE)
- {
- $field['type'] = 'INTEGER PRIMARY KEY';
- $field['default'] = '';
- $field['null'] = '';
- $field['unique'] = '';
- $field['auto_increment'] = ' AUTOINCREMENT';
- $this->primary_keys = array();
- }
- }
- }
|