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. |
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 10 | * @license http://www.codeignitor.com/user_guide/license.html |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 11 | * @link http://www.codeigniter.com |
| 12 | * @since Version 1.0 |
| 13 | * @filesource |
| 14 | */ |
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 15 | |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 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 | b2a9cec | 2006-10-01 03:38:04 +0000 | [diff] [blame] | 67 | * List databases |
| 68 | * |
| 69 | * I don't believe you can do a database listing with SQLite |
| 70 | * since each database is its own file. I suppose we could |
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 71 | * try reading a directory looking for SQLite files, but |
admin | b2a9cec | 2006-10-01 03:38:04 +0000 | [diff] [blame] | 72 | * that doesn't seem like a terribly good idea |
| 73 | * |
| 74 | * @access private |
| 75 | * @return bool |
| 76 | */ |
| 77 | function _list_databases() |
| 78 | { |
| 79 | if ($this->db_debug) |
| 80 | { |
| 81 | return $this->display_error('db_unsuported_feature'); |
| 82 | } |
| 83 | return array(); |
| 84 | } |
| 85 | |
| 86 | // -------------------------------------------------------------------- |
| 87 | |
| 88 | /** |
admin | 4ceac2d | 2006-09-25 06:40:16 +0000 | [diff] [blame] | 89 | * Drop Table |
| 90 | * |
admin | 4a2ed69 | 2006-09-29 01:14:52 +0000 | [diff] [blame] | 91 | * Unsupported feature in SQLite |
| 92 | * |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 93 | * @access private |
admin | 4ceac2d | 2006-09-25 06:40:16 +0000 | [diff] [blame] | 94 | * @return bool |
| 95 | */ |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 96 | function _drop_table($table) |
admin | 4ceac2d | 2006-09-25 06:40:16 +0000 | [diff] [blame] | 97 | { |
admin | 3dd978f | 2006-09-30 19:24:45 +0000 | [diff] [blame] | 98 | if ($this->db->db_debug) |
admin | 4ceac2d | 2006-09-25 06:40:16 +0000 | [diff] [blame] | 99 | { |
admin | 3dd978f | 2006-09-30 19:24:45 +0000 | [diff] [blame] | 100 | return $this->db->display_error('db_unsuported_feature'); |
admin | 4ceac2d | 2006-09-25 06:40:16 +0000 | [diff] [blame] | 101 | } |
| 102 | return array(); |
| 103 | } |
| 104 | |
| 105 | // -------------------------------------------------------------------- |
| 106 | |
| 107 | /** |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 108 | * Optimize table query |
| 109 | * |
admin | 4a2ed69 | 2006-09-29 01:14:52 +0000 | [diff] [blame] | 110 | * Is optimization even supported in SQLite? |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 111 | * |
| 112 | * @access private |
| 113 | * @param string the table name |
| 114 | * @return object |
| 115 | */ |
| 116 | function _optimize_table($table) |
| 117 | { |
admin | 4a2ed69 | 2006-09-29 01:14:52 +0000 | [diff] [blame] | 118 | return FALSE; |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | // -------------------------------------------------------------------- |
| 122 | |
| 123 | /** |
| 124 | * Repair table query |
| 125 | * |
admin | 4a2ed69 | 2006-09-29 01:14:52 +0000 | [diff] [blame] | 126 | * Are table repairs even supported in SQLite? |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 127 | * |
| 128 | * @access private |
| 129 | * @param string the table name |
| 130 | * @return object |
| 131 | */ |
| 132 | function _repair_table($table) |
| 133 | { |
admin | 9a66181 | 2006-10-16 19:02:48 +0000 | [diff] [blame] | 134 | return FALSE; |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 135 | } |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 136 | |
admin | 3cad41e | 2006-10-02 03:21:46 +0000 | [diff] [blame] | 137 | // -------------------------------------------------------------------- |
| 138 | |
| 139 | /** |
| 140 | * SQLite Export |
| 141 | * |
| 142 | * @access private |
| 143 | * @param array Preferences |
| 144 | * @return mixed |
| 145 | */ |
| 146 | function _backup($params = array()) |
| 147 | { |
| 148 | // Currently unsupported |
| 149 | return $this->db->display_error('db_unsuported_feature'); |
| 150 | } |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 151 | |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | ?> |