blob: cf15104c6e2afd97c3971bf9608715cafca036bf [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 * MS SQL 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_mssql_utility extends CI_DB_utility {
26
admin6ca6f942006-09-25 02:51:08 +000027
28 /**
29 * Create database
30 *
admin6cec6a52006-09-25 06:56:49 +000031 * @access private
admin6ca6f942006-09-25 02:51:08 +000032 * @param string the database name
33 * @return bool
34 */
admin6cec6a52006-09-25 06:56:49 +000035 function _create_database($name)
admin6ca6f942006-09-25 02:51:08 +000036 {
admin6cec6a52006-09-25 06:56:49 +000037 return "CREATE DATABASE ".$name;
admin6ca6f942006-09-25 02:51:08 +000038 }
39
40 // --------------------------------------------------------------------
41
42 /**
43 * Drop database
44 *
admin83b05a82006-09-25 21:06:46 +000045 * @access private
admin6ca6f942006-09-25 02:51:08 +000046 * @param string the database name
47 * @return bool
48 */
admin83b05a82006-09-25 21:06:46 +000049 function _drop_database($name)
admin6ca6f942006-09-25 02:51:08 +000050 {
admin83b05a82006-09-25 21:06:46 +000051 return "DROP DATABASE ".$name;
admin6ca6f942006-09-25 02:51:08 +000052 }
53
54 // --------------------------------------------------------------------
admin72496372006-09-25 03:44:04 +000055
56 /**
57 * List databases
58 *
admin83b05a82006-09-25 21:06:46 +000059 * @access private
admin72496372006-09-25 03:44:04 +000060 * @return bool
61 */
admin83b05a82006-09-25 21:06:46 +000062 function _list_databases()
admin72496372006-09-25 03:44:04 +000063 {
admin83b05a82006-09-25 21:06:46 +000064 return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
admin72496372006-09-25 03:44:04 +000065 }
66
67 // --------------------------------------------------------------------
admin4ceac2d2006-09-25 06:40:16 +000068
69 /**
70 * Drop Table
71 *
admin83b05a82006-09-25 21:06:46 +000072 * @access private
admin4ceac2d2006-09-25 06:40:16 +000073 * @return bool
74 */
admin83b05a82006-09-25 21:06:46 +000075 function _drop_table($table)
admin4ceac2d2006-09-25 06:40:16 +000076 {
admin83b05a82006-09-25 21:06:46 +000077 return "DROP TABLE ".$this->db->_escape_table($name);
admin4ceac2d2006-09-25 06:40:16 +000078 }
79
80 // --------------------------------------------------------------------
admin7b613c72006-09-24 18:05:17 +000081
82 /**
admina5e812c2006-09-25 02:17:30 +000083 * Version number query string
admin7b613c72006-09-24 18:05:17 +000084 *
85 * @access public
admina5e812c2006-09-25 02:17:30 +000086 * @return string
admin7b613c72006-09-24 18:05:17 +000087 */
admina5e812c2006-09-25 02:17:30 +000088 function _version()
admin7b613c72006-09-24 18:05:17 +000089 {
admina5e812c2006-09-25 02:17:30 +000090 return "SELECT version() AS ver";
admin7b613c72006-09-24 18:05:17 +000091 }
92
93 // --------------------------------------------------------------------
94
admina5e812c2006-09-25 02:17:30 +000095 /**
96 * Show table query
97 *
98 * Generates a platform-specific query string so that the table names can be fetched
99 *
100 * @access public
101 * @return string
102 */
103 function _show_tables()
104 {
105 return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
106 }
107
108 // --------------------------------------------------------------------
109
110 /**
111 * Show columnn query
112 *
113 * Generates a platform-specific query string so that the column names can be fetched
114 *
115 * @access public
116 * @param string the table name
117 * @return string
118 */
119 function _show_columns($table = '')
120 {
121 return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->db->_escape_table($table)."'";
122 }
123
124 // --------------------------------------------------------------------
125
126 /**
127 * Field data query
128 *
129 * Generates a platform-specific query so that the column data can be retrieved
130 *
131 * @access public
132 * @param string the table name
133 * @return object
134 */
135 function _field_data($table)
136 {
admin6cec6a52006-09-25 06:56:49 +0000137 return "SELECT TOP 1 FROM ".$this->db->_escape_table($table);
admina5e812c2006-09-25 02:17:30 +0000138 }
139
140
adminab4f61b2006-09-25 22:12:32 +0000141 // --------------------------------------------------------------------
142
143 /**
144 * Optimize table query
145 *
146 * Generates a platform-specific query so that a table can be optimized
147 *
148 * @access private
149 * @param string the table name
150 * @return object
151 */
152 function _optimize_table($table)
153 {
154 return FALSE; // Is this supported in MS SQL?
155 }
156
157 // --------------------------------------------------------------------
158
159 /**
160 * Repair table query
161 *
162 * Generates a platform-specific query so that a table can be repaired
163 *
164 * @access private
165 * @param string the table name
166 * @return object
167 */
168 function _repair_table($table)
169 {
170 return return FALSE; // Is this supported in MS SQL?
171 }
admina5e812c2006-09-25 02:17:30 +0000172
admin7b613c72006-09-24 18:05:17 +0000173}
174
175?>