blob: 9ff92d41b7024eaef752d5e1d94e5560d4c3e0c8 [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 *
31 * @access public
32 * @param string the database name
33 * @return bool
34 */
35 function create_database($name)
36 {
37 return $this->db->query("CREATE DATABASE ".$this->db->_escape_table($name));
38 }
39
40 // --------------------------------------------------------------------
41
42 /**
43 * Drop database
44 *
45 * @access public
46 * @param string the database name
47 * @return bool
48 */
49 function drop_database($name)
50 {
51 return $this->db->query("DROP DATABASE ".$this->db->_escape_table($name));
52 }
53
54 // --------------------------------------------------------------------
admin7b613c72006-09-24 18:05:17 +000055
56 /**
admina5e812c2006-09-25 02:17:30 +000057 * Version number query string
admin7b613c72006-09-24 18:05:17 +000058 *
59 * @access public
admina5e812c2006-09-25 02:17:30 +000060 * @return string
admin7b613c72006-09-24 18:05:17 +000061 */
admina5e812c2006-09-25 02:17:30 +000062 function _version()
admin7b613c72006-09-24 18:05:17 +000063 {
admina5e812c2006-09-25 02:17:30 +000064 return "SELECT version() AS ver";
admin7b613c72006-09-24 18:05:17 +000065 }
66
67 // --------------------------------------------------------------------
68
admina5e812c2006-09-25 02:17:30 +000069 /**
70 * Show table query
71 *
72 * Generates a platform-specific query string so that the table names can be fetched
73 *
74 * @access public
75 * @return string
76 */
77 function _show_tables()
78 {
79 return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
80 }
81
82 // --------------------------------------------------------------------
83
84 /**
85 * Show columnn query
86 *
87 * Generates a platform-specific query string so that the column names can be fetched
88 *
89 * @access public
90 * @param string the table name
91 * @return string
92 */
93 function _show_columns($table = '')
94 {
95 return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->db->_escape_table($table)."'";
96 }
97
98 // --------------------------------------------------------------------
99
100 /**
101 * Field data query
102 *
103 * Generates a platform-specific query so that the column data can be retrieved
104 *
105 * @access public
106 * @param string the table name
107 * @return object
108 */
109 function _field_data($table)
110 {
111 $sql = "SELECT TOP 1 FROM ".$this->db->_escape_table($table);
112 $query = $this->db->query($sql);
113 return $query->field_data();
114 }
115
116
117
admin7b613c72006-09-24 18:05:17 +0000118}
119
120?>