blob: 8c9e1e960cdbe117b6f609a0b2a3e5f210055227 [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 * MySQLi 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_mysqli_utility extends CI_DB_utility {
admin7b613c72006-09-24 18:05:17 +000026
27 /**
admin6ca6f942006-09-25 02:51:08 +000028 * Create database
29 *
admin6cec6a52006-09-25 06:56:49 +000030 * @access private
admin6ca6f942006-09-25 02:51:08 +000031 * @param string the database name
32 * @return bool
33 */
admin6cec6a52006-09-25 06:56:49 +000034 function _create_database($name)
admin6ca6f942006-09-25 02:51:08 +000035 {
admin6cec6a52006-09-25 06:56:49 +000036 return "CREATE DATABASE ".$name;
admin6ca6f942006-09-25 02:51:08 +000037 }
38
39 // --------------------------------------------------------------------
40
41 /**
42 * Drop database
43 *
admin83b05a82006-09-25 21:06:46 +000044 * @access private
admin6ca6f942006-09-25 02:51:08 +000045 * @param string the database name
46 * @return bool
47 */
admin83b05a82006-09-25 21:06:46 +000048 function _drop_database($name)
admin6ca6f942006-09-25 02:51:08 +000049 {
admin83b05a82006-09-25 21:06:46 +000050 return "DROP DATABASE ".$name;
admin6ca6f942006-09-25 02:51:08 +000051 }
52
53 // --------------------------------------------------------------------
54
55 /**
admin72496372006-09-25 03:44:04 +000056 * List databases
57 *
admin83b05a82006-09-25 21:06:46 +000058 * @access private
admin72496372006-09-25 03:44:04 +000059 * @return bool
60 */
admin83b05a82006-09-25 21:06:46 +000061 function _list_databases()
admin72496372006-09-25 03:44:04 +000062 {
admin83b05a82006-09-25 21:06:46 +000063 return "SHOW DATABASES";
admin72496372006-09-25 03:44:04 +000064 }
admin4ceac2d2006-09-25 06:40:16 +000065
66 // --------------------------------------------------------------------
67
68 /**
69 * Drop Table
70 *
admin83b05a82006-09-25 21:06:46 +000071 * @access private
admin4ceac2d2006-09-25 06:40:16 +000072 * @return bool
73 */
admin83b05a82006-09-25 21:06:46 +000074 function _drop_table($table)
admin4ceac2d2006-09-25 06:40:16 +000075 {
admin83b05a82006-09-25 21:06:46 +000076 return "DROP TABLE IF EXISTS ".$this->db->_escape_table($name);
admin4ceac2d2006-09-25 06:40:16 +000077 }
admin72496372006-09-25 03:44:04 +000078
79 // --------------------------------------------------------------------
80
81 /**
admina5e812c2006-09-25 02:17:30 +000082 * Version number query string
admin7b613c72006-09-24 18:05:17 +000083 *
84 * @access public
admina5e812c2006-09-25 02:17:30 +000085 * @return string
admin7b613c72006-09-24 18:05:17 +000086 */
admina5e812c2006-09-25 02:17:30 +000087 function _version()
admin7b613c72006-09-24 18:05:17 +000088 {
admina5e812c2006-09-25 02:17:30 +000089 return "SELECT version() AS ver";
admin7b613c72006-09-24 18:05:17 +000090 }
91
92 // --------------------------------------------------------------------
93
admina5e812c2006-09-25 02:17:30 +000094 /**
95 * Show table query
96 *
97 * Generates a platform-specific query string so that the table names can be fetched
98 *
99 * @access public
100 * @return string
101 */
102 function _show_tables()
103 {
104 return "SHOW TABLES FROM `".$this->db->database."`";
105 }
106
107 // --------------------------------------------------------------------
108
109 /**
110 * Show columnn query
111 *
112 * Generates a platform-specific query string so that the column names can be fetched
113 *
114 * @access public
115 * @param string the table name
116 * @return string
117 */
118 function _show_columns($table = '')
119 {
120 return "SHOW COLUMNS FROM ".$this->db->_escape_table($table);
121 }
122
123 // --------------------------------------------------------------------
124
125 /**
126 * Field data query
127 *
128 * Generates a platform-specific query so that the column data can be retrieved
129 *
130 * @access public
131 * @param string the table name
132 * @return object
133 */
134 function _field_data($table)
135 {
admin6cec6a52006-09-25 06:56:49 +0000136 return "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1";
admina5e812c2006-09-25 02:17:30 +0000137 }
138
adminab4f61b2006-09-25 22:12:32 +0000139 // --------------------------------------------------------------------
140
141 /**
142 * Optimize table query
143 *
144 * Generates a platform-specific query so that a table can be optimized
145 *
146 * @access private
147 * @param string the table name
148 * @return object
149 */
150 function _optimize_table($table)
151 {
152 return "OPTIMIZE TABLE ".$this->db->_escape_table($table);
153 }
154
155 // --------------------------------------------------------------------
156
157 /**
158 * Repair table query
159 *
160 * Generates a platform-specific query so that a table can be repaired
161 *
162 * @access private
163 * @param string the table name
164 * @return object
165 */
166 function _repair_table($table)
167 {
168 return "REPAIR TABLE ".$this->db->_escape_table($table);
169 }
admina5e812c2006-09-25 02:17:30 +0000170
171
admin7b613c72006-09-24 18:05:17 +0000172}
173
174?>