blob: 9cb2cf02750179d1e57897073df476a30b7a6e2e [file] [log] [blame]
admin7b613c72006-09-24 18:05:17 +00001<?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 */
admina5e812c2006-09-25 02:17:30 +000025class CI_DB_sqlite_utility extends CI_DB_utility {
26
admin6ca6f942006-09-25 02:51:08 +000027
28 /**
29 * Create database
30 *
31 * @access public
32 * @param string the database name
33 * @return bool
34 */
admin6cec6a52006-09-25 06:56:49 +000035 function _create_database()
admin6ca6f942006-09-25 02:51:08 +000036 {
admin4a2ed692006-09-29 01:14:52 +000037 // In SQLite, a database is created when you connect to the database.
38 // We'll return TRUE so that an error isn't generated
admin6ca6f942006-09-25 02:51:08 +000039 return TRUE;
40 }
41
42 // --------------------------------------------------------------------
43
44 /**
45 * Drop database
46 *
admin83b05a82006-09-25 21:06:46 +000047 * @access private
admin6ca6f942006-09-25 02:51:08 +000048 * @param string the database name
49 * @return bool
50 */
admin83b05a82006-09-25 21:06:46 +000051 function _drop_database($name)
admin6ca6f942006-09-25 02:51:08 +000052 {
53 if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
54 {
admin3dd978f2006-09-30 19:24:45 +000055 if ($this->db->db_debug)
admin6ca6f942006-09-25 02:51:08 +000056 {
admin3dd978f2006-09-30 19:24:45 +000057 return $this->db->display_error('db_unable_to_drop');
admin6ca6f942006-09-25 02:51:08 +000058 }
59 return FALSE;
60 }
61 return TRUE;
62 }
63
64 // --------------------------------------------------------------------
65
admin7b613c72006-09-24 18:05:17 +000066 /**
adminb2a9cec2006-10-01 03:38:04 +000067 * 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
71 * try reading a directory looking for SQLite files, but
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 /**
admin4ceac2d2006-09-25 06:40:16 +000089 * Drop Table
90 *
admin4a2ed692006-09-29 01:14:52 +000091 * Unsupported feature in SQLite
92 *
admin83b05a82006-09-25 21:06:46 +000093 * @access private
admin4ceac2d2006-09-25 06:40:16 +000094 * @return bool
95 */
admin83b05a82006-09-25 21:06:46 +000096 function _drop_table($table)
admin4ceac2d2006-09-25 06:40:16 +000097 {
admin3dd978f2006-09-30 19:24:45 +000098 if ($this->db->db_debug)
admin4ceac2d2006-09-25 06:40:16 +000099 {
admin3dd978f2006-09-30 19:24:45 +0000100 return $this->db->display_error('db_unsuported_feature');
admin4ceac2d2006-09-25 06:40:16 +0000101 }
102 return array();
103 }
104
105 // --------------------------------------------------------------------
106
107 /**
adminab4f61b2006-09-25 22:12:32 +0000108 * Optimize table query
109 *
admin4a2ed692006-09-29 01:14:52 +0000110 * Is optimization even supported in SQLite?
adminab4f61b2006-09-25 22:12:32 +0000111 *
112 * @access private
113 * @param string the table name
114 * @return object
115 */
116 function _optimize_table($table)
117 {
admin4a2ed692006-09-29 01:14:52 +0000118 return FALSE;
adminab4f61b2006-09-25 22:12:32 +0000119 }
120
121 // --------------------------------------------------------------------
122
123 /**
124 * Repair table query
125 *
admin4a2ed692006-09-29 01:14:52 +0000126 * Are table repairs even supported in SQLite?
adminab4f61b2006-09-25 22:12:32 +0000127 *
128 * @access private
129 * @param string the table name
130 * @return object
131 */
132 function _repair_table($table)
133 {
admin4a2ed692006-09-29 01:14:52 +0000134 return return FALSE;
adminab4f61b2006-09-25 22:12:32 +0000135 }
admina5e812c2006-09-25 02:17:30 +0000136
admin3cad41e2006-10-02 03:21:46 +0000137 // --------------------------------------------------------------------
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 }
admina5e812c2006-09-25 02:17:30 +0000151
admin7b613c72006-09-24 18:05:17 +0000152}
153
154?>