blob: ae241db87f7624c0d9ed00799eb7b67e69bab1fb [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 {
55 if ($this->db_debug)
56 {
57 return $this->display_error('db_unable_to_drop');
58 }
59 return FALSE;
60 }
61 return TRUE;
62 }
63
64 // --------------------------------------------------------------------
65
admin7b613c72006-09-24 18:05:17 +000066 /**
admin72496372006-09-25 03:44:04 +000067 * List databases
68 *
admin4a2ed692006-09-29 01:14:52 +000069 * 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 *
admin83b05a82006-09-25 21:06:46 +000074 * @access private
admin72496372006-09-25 03:44:04 +000075 * @return bool
76 */
admin83b05a82006-09-25 21:06:46 +000077 function _list_databases()
admin72496372006-09-25 03:44:04 +000078 {
admin4a2ed692006-09-29 01:14:52 +000079
admin72496372006-09-25 03:44:04 +000080 if ($this->db_debug)
81 {
82 return $this->display_error('db_unsuported_feature');
83 }
84 return array();
85 }
86
87 // --------------------------------------------------------------------
88
89 /**
admin9cd4e8e2006-09-25 23:26:25 +000090 * Show table query
91 *
92 * Generates a platform-specific query string so that the table names can be fetched
93 *
94 * @access private
95 * @return string
96 */
97 function _list_tables()
98 {
99 return "SELECT name from sqlite_master WHERE type='table'";
100 }
101
102 // --------------------------------------------------------------------
103
104 /**
admin4ceac2d2006-09-25 06:40:16 +0000105 * Drop Table
106 *
admin4a2ed692006-09-29 01:14:52 +0000107 * Unsupported feature in SQLite
108 *
admin83b05a82006-09-25 21:06:46 +0000109 * @access private
admin4ceac2d2006-09-25 06:40:16 +0000110 * @return bool
111 */
admin83b05a82006-09-25 21:06:46 +0000112 function _drop_table($table)
admin4ceac2d2006-09-25 06:40:16 +0000113 {
114 if ($this->db_debug)
115 {
116 return $this->display_error('db_unsuported_feature');
117 }
118 return array();
119 }
120
121 // --------------------------------------------------------------------
122
123 /**
adminab4f61b2006-09-25 22:12:32 +0000124 * Optimize table query
125 *
admin4a2ed692006-09-29 01:14:52 +0000126 * Is optimization 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 _optimize_table($table)
133 {
admin4a2ed692006-09-29 01:14:52 +0000134 return FALSE;
adminab4f61b2006-09-25 22:12:32 +0000135 }
136
137 // --------------------------------------------------------------------
138
139 /**
140 * Repair table query
141 *
admin4a2ed692006-09-29 01:14:52 +0000142 * Are table repairs even supported in SQLite?
adminab4f61b2006-09-25 22:12:32 +0000143 *
144 * @access private
145 * @param string the table name
146 * @return object
147 */
148 function _repair_table($table)
149 {
admin4a2ed692006-09-29 01:14:52 +0000150 return return FALSE;
adminab4f61b2006-09-25 22:12:32 +0000151 }
admina5e812c2006-09-25 02:17:30 +0000152
153
admin7b613c72006-09-24 18:05:17 +0000154}
155
156?>