admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
| 2 | /** |
| 3 | * Code Igniter |
| 4 | * |
| 5 | * An open source application development framework for PHP 4.3.2 or newer |
| 6 | * |
| 7 | * @package CodeIgniter |
| 8 | * @author Rick Ellis |
| 9 | * @copyright Copyright (c) 2006, pMachine, Inc. |
| 10 | * @license http://www.codeignitor.com/user_guide/license.html |
| 11 | * @link http://www.codeigniter.com |
| 12 | * @since Version 1.0 |
| 13 | * @filesource |
| 14 | */ |
| 15 | |
| 16 | // ------------------------------------------------------------------------ |
| 17 | |
| 18 | /** |
| 19 | * SQLite Utility Class |
| 20 | * |
| 21 | * @category Database |
| 22 | * @author Rick Ellis |
| 23 | * @link http://www.codeigniter.com/user_guide/database/ |
| 24 | */ |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 25 | class CI_DB_sqlite_utility extends CI_DB_utility { |
| 26 | |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * Create database |
| 30 | * |
| 31 | * @access public |
| 32 | * @param string the database name |
| 33 | * @return bool |
| 34 | */ |
admin | 6cec6a5 | 2006-09-25 06:56:49 +0000 | [diff] [blame] | 35 | function _create_database() |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame] | 36 | { |
admin | 4a2ed69 | 2006-09-29 01:14:52 +0000 | [diff] [blame] | 37 | // In SQLite, a database is created when you connect to the database. |
| 38 | // We'll return TRUE so that an error isn't generated |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame] | 39 | return TRUE; |
| 40 | } |
| 41 | |
| 42 | // -------------------------------------------------------------------- |
| 43 | |
| 44 | /** |
| 45 | * Drop database |
| 46 | * |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 47 | * @access private |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame] | 48 | * @param string the database name |
| 49 | * @return bool |
| 50 | */ |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 51 | function _drop_database($name) |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame] | 52 | { |
| 53 | if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database)) |
| 54 | { |
admin | 3dd978f | 2006-09-30 19:24:45 +0000 | [diff] [blame^] | 55 | if ($this->db->db_debug) |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame] | 56 | { |
admin | 3dd978f | 2006-09-30 19:24:45 +0000 | [diff] [blame^] | 57 | return $this->db->display_error('db_unable_to_drop'); |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame] | 58 | } |
| 59 | return FALSE; |
| 60 | } |
| 61 | return TRUE; |
| 62 | } |
| 63 | |
| 64 | // -------------------------------------------------------------------- |
| 65 | |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 66 | /** |
admin | 4ceac2d | 2006-09-25 06:40:16 +0000 | [diff] [blame] | 67 | * Drop Table |
| 68 | * |
admin | 4a2ed69 | 2006-09-29 01:14:52 +0000 | [diff] [blame] | 69 | * Unsupported feature in SQLite |
| 70 | * |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 71 | * @access private |
admin | 4ceac2d | 2006-09-25 06:40:16 +0000 | [diff] [blame] | 72 | * @return bool |
| 73 | */ |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 74 | function _drop_table($table) |
admin | 4ceac2d | 2006-09-25 06:40:16 +0000 | [diff] [blame] | 75 | { |
admin | 3dd978f | 2006-09-30 19:24:45 +0000 | [diff] [blame^] | 76 | if ($this->db->db_debug) |
admin | 4ceac2d | 2006-09-25 06:40:16 +0000 | [diff] [blame] | 77 | { |
admin | 3dd978f | 2006-09-30 19:24:45 +0000 | [diff] [blame^] | 78 | return $this->db->display_error('db_unsuported_feature'); |
admin | 4ceac2d | 2006-09-25 06:40:16 +0000 | [diff] [blame] | 79 | } |
| 80 | return array(); |
| 81 | } |
| 82 | |
| 83 | // -------------------------------------------------------------------- |
| 84 | |
| 85 | /** |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 86 | * Optimize table query |
| 87 | * |
admin | 4a2ed69 | 2006-09-29 01:14:52 +0000 | [diff] [blame] | 88 | * Is optimization even supported in SQLite? |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 89 | * |
| 90 | * @access private |
| 91 | * @param string the table name |
| 92 | * @return object |
| 93 | */ |
| 94 | function _optimize_table($table) |
| 95 | { |
admin | 4a2ed69 | 2006-09-29 01:14:52 +0000 | [diff] [blame] | 96 | return FALSE; |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | // -------------------------------------------------------------------- |
| 100 | |
| 101 | /** |
| 102 | * Repair table query |
| 103 | * |
admin | 4a2ed69 | 2006-09-29 01:14:52 +0000 | [diff] [blame] | 104 | * Are table repairs even supported in SQLite? |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 105 | * |
| 106 | * @access private |
| 107 | * @param string the table name |
| 108 | * @return object |
| 109 | */ |
| 110 | function _repair_table($table) |
| 111 | { |
admin | 4a2ed69 | 2006-09-29 01:14:52 +0000 | [diff] [blame] | 112 | return return FALSE; |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 113 | } |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 114 | |
| 115 | |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | ?> |