admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 1 | <?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 | * ODBC Utility Class |
| 20 | * |
| 21 | * @category Database |
| 22 | * @author Rick Ellis |
| 23 | * @link http://www.codeigniter.com/database/ |
| 24 | */ |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 25 | class CI_DB_odbc_utility extends CI_DB_utility { |
| 26 | |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame] | 27 | |
| 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 | // ODBC has no "create database" command since it's |
| 38 | // designed to connect to an existing database |
admin | 7249637 | 2006-09-25 03:44:04 +0000 | [diff] [blame^] | 39 | if ($this->db_debug) |
| 40 | { |
| 41 | return $this->display_error('db_unsuported_feature'); |
| 42 | } |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame] | 43 | return FALSE; |
| 44 | } |
| 45 | |
| 46 | // -------------------------------------------------------------------- |
| 47 | |
| 48 | /** |
| 49 | * Drop database |
| 50 | * |
| 51 | * @access public |
| 52 | * @param string the database name |
| 53 | * @return bool |
| 54 | */ |
| 55 | function drop_database($name) |
| 56 | { |
| 57 | // ODBC has no "drop database" command since it's |
admin | 7249637 | 2006-09-25 03:44:04 +0000 | [diff] [blame^] | 58 | // designed to connect to an existing database |
| 59 | if ($this->db_debug) |
| 60 | { |
| 61 | return $this->display_error('db_unsuported_feature'); |
| 62 | } |
| 63 | return FALSE; |
| 64 | } |
| 65 | |
| 66 | // -------------------------------------------------------------------- |
| 67 | |
| 68 | /** |
| 69 | * List databases |
| 70 | * |
| 71 | * @access public |
| 72 | * @return bool |
| 73 | */ |
| 74 | function list_databases() |
| 75 | { |
| 76 | // Not sure if ODBC lets you list all databases... |
| 77 | if ($this->db_debug) |
| 78 | { |
| 79 | return $this->display_error('db_unsuported_feature'); |
| 80 | } |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame] | 81 | return FALSE; |
| 82 | } |
| 83 | |
| 84 | // -------------------------------------------------------------------- |
| 85 | |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 86 | /** |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 87 | * Version number query string |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 88 | * |
| 89 | * @access public |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 90 | * @return string |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 91 | */ |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 92 | function _version() |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 93 | { |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 94 | return "SELECT version() AS ver"; |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | // -------------------------------------------------------------------- |
| 98 | |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 99 | /** |
| 100 | * Show table query |
| 101 | * |
| 102 | * Generates a platform-specific query string so that the table names can be fetched |
| 103 | * |
| 104 | * @access public |
| 105 | * @return string |
| 106 | */ |
| 107 | function _show_tables() |
| 108 | { |
| 109 | return "SHOW TABLES FROM `".$this->db->database."`"; |
| 110 | } |
| 111 | |
| 112 | // -------------------------------------------------------------------- |
| 113 | |
| 114 | /** |
| 115 | * Show columnn query |
| 116 | * |
| 117 | * Generates a platform-specific query string so that the column names can be fetched |
| 118 | * |
| 119 | * @access public |
| 120 | * @param string the table name |
| 121 | * @return string |
| 122 | */ |
| 123 | function _show_columns($table = '') |
| 124 | { |
| 125 | return "SHOW COLUMNS FROM ".$this->db->_escape_table($table); |
| 126 | } |
| 127 | |
| 128 | // -------------------------------------------------------------------- |
| 129 | |
| 130 | /** |
| 131 | * Field data query |
| 132 | * |
| 133 | * Generates a platform-specific query so that the column data can be retrieved |
| 134 | * |
| 135 | * @access public |
| 136 | * @param string the table name |
| 137 | * @return object |
| 138 | */ |
| 139 | function _field_data($table) |
| 140 | { |
| 141 | $sql = "SELECT TOP 1 FROM ".$this->db->_escape_table($table); |
| 142 | $query = $this->db->query($sql); |
| 143 | return $query->field_data(); |
| 144 | } |
| 145 | |
| 146 | |
| 147 | |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | ?> |