blob: 8cbf0d56d63d42d478eddaae7d822e0263b0f64d [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 */
35 function create_database()
36 {
37 // In SQLite, a database is created when you connect to the database
38 return TRUE;
39 }
40
41 // --------------------------------------------------------------------
42
43 /**
44 * Drop database
45 *
46 * @access public
47 * @param string the database name
48 * @return bool
49 */
50 function drop_database($name)
51 {
52 if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
53 {
54 if ($this->db_debug)
55 {
56 return $this->display_error('db_unable_to_drop');
57 }
58 return FALSE;
59 }
60 return TRUE;
61 }
62
63 // --------------------------------------------------------------------
64
admin7b613c72006-09-24 18:05:17 +000065 /**
admina5e812c2006-09-25 02:17:30 +000066 * Version number query string
admin7b613c72006-09-24 18:05:17 +000067 *
68 * @access public
admina5e812c2006-09-25 02:17:30 +000069 * @return string
admin7b613c72006-09-24 18:05:17 +000070 */
admina5e812c2006-09-25 02:17:30 +000071 function _version()
admin7b613c72006-09-24 18:05:17 +000072 {
admina5e812c2006-09-25 02:17:30 +000073 return sqlite_libversion();
74 }
75
76 // --------------------------------------------------------------------
77
78 /**
79 * Show table query
80 *
81 * Generates a platform-specific query string so that the table names can be fetched
82 *
83 * @access public
84 * @return string
85 */
86 function _show_tables()
87 {
88 return "SELECT name from sqlite_master WHERE type='table'";
admin7b613c72006-09-24 18:05:17 +000089 }
90
91 // --------------------------------------------------------------------
92
admina5e812c2006-09-25 02:17:30 +000093 /**
94 * Show columnn query
95 *
96 * Generates a platform-specific query string so that the column names can be fetched
97 *
98 * @access public
99 * @param string the table name
100 * @return string
101 */
102 function _show_columns($table = '')
103 {
104 // Not supported
105 return FALSE;
106 }
107
108 // --------------------------------------------------------------------
109
110 /**
111 * Field data query
112 *
113 * Generates a platform-specific query so that the column data can be retrieved
114 *
115 * @access public
116 * @param string the table name
117 * @return object
118 */
119 function _field_data($table)
120 {
121 $sql = "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1";
122 $query = $this->db->query($sql);
123 return $query->field_data();
124 }
125
126
127
admin7b613c72006-09-24 18:05:17 +0000128}
129
130?>