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. |
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 10 | * @license http://www.codeignitor.com/user_guide/license.html |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 11 | * @link http://www.codeigniter.com |
| 12 | * @since Version 1.0 |
| 13 | * @filesource |
| 14 | */ |
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 15 | |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 16 | // ------------------------------------------------------------------------ |
| 17 | |
| 18 | /** |
| 19 | * MS SQL Result Class |
| 20 | * |
| 21 | * This class extends the parent result class: CI_DB_result |
| 22 | * |
| 23 | * @category Database |
| 24 | * @author Rick Ellis |
| 25 | * @link http://www.codeigniter.com/user_guide/database/ |
| 26 | */ |
| 27 | class CI_DB_mssql_result extends CI_DB_result { |
| 28 | |
| 29 | /** |
| 30 | * Number of rows in the result set |
| 31 | * |
| 32 | * @access public |
| 33 | * @return integer |
| 34 | */ |
| 35 | function num_rows() |
| 36 | { |
| 37 | return @mssql_num_rows($this->result_id); |
| 38 | } |
| 39 | |
| 40 | // -------------------------------------------------------------------- |
| 41 | |
| 42 | /** |
| 43 | * Number of fields in the result set |
| 44 | * |
| 45 | * @access public |
| 46 | * @return integer |
| 47 | */ |
| 48 | function num_fields() |
| 49 | { |
| 50 | return @mssql_num_fields($this->result_id); |
| 51 | } |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 52 | |
| 53 | // -------------------------------------------------------------------- |
| 54 | |
| 55 | /** |
| 56 | * Fetch Field Names |
| 57 | * |
| 58 | * Generates an array of column names |
| 59 | * |
| 60 | * @access public |
| 61 | * @return array |
| 62 | */ |
admin | 606f99c | 2006-10-11 23:48:41 +0000 | [diff] [blame] | 63 | function list_fields() |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 64 | { |
| 65 | $field_names = array(); |
| 66 | while ($field = mssql_fetch_field($this->result_id)) |
| 67 | { |
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 68 | $field_names[] = $field->name; |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | return $field_names; |
| 72 | } |
admin | 606f99c | 2006-10-11 23:48:41 +0000 | [diff] [blame] | 73 | |
| 74 | // Deprecated |
| 75 | function field_names() |
| 76 | { |
| 77 | return $this->list_fields(); |
| 78 | } |
admin | ab4f61b | 2006-09-25 22:12:32 +0000 | [diff] [blame] | 79 | |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 80 | // -------------------------------------------------------------------- |
| 81 | |
| 82 | /** |
| 83 | * Field data |
| 84 | * |
| 85 | * Generates an array of objects containing field meta-data |
| 86 | * |
| 87 | * @access public |
| 88 | * @return array |
| 89 | */ |
| 90 | function field_data() |
| 91 | { |
| 92 | $retval = array(); |
| 93 | while ($field = mssql_fetch_field($this->result_id)) |
| 94 | { |
| 95 | $F = new stdClass(); |
| 96 | $F->name = $field->name; |
| 97 | $F->type = $field->type; |
| 98 | $F->max_length = $field->max_length; |
| 99 | $F->primary_key = 0; |
| 100 | $F->default = ''; |
| 101 | |
| 102 | $retval[] = $F; |
| 103 | } |
| 104 | |
| 105 | return $retval; |
| 106 | } |
| 107 | |
| 108 | // -------------------------------------------------------------------- |
| 109 | |
| 110 | /** |
| 111 | * Free the result |
| 112 | * |
| 113 | * @return null |
| 114 | */ |
| 115 | function free_result() |
| 116 | { |
| 117 | if (is_resource($this->result_id)) |
| 118 | { |
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 119 | mssql_free_result($this->result_id); |
| 120 | $this->result_id = FALSE; |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 121 | } |
| 122 | } |
admin | d2dd031 | 2006-10-05 04:34:38 +0000 | [diff] [blame] | 123 | |
| 124 | // -------------------------------------------------------------------- |
| 125 | |
| 126 | /** |
| 127 | * Data Seek |
| 128 | * |
| 129 | * Moves the internal pointer to the desired offset. We call |
| 130 | * this internally before fetching results to make sure the |
| 131 | * result set starts at zero |
| 132 | * |
| 133 | * @access private |
| 134 | * @return array |
| 135 | */ |
| 136 | function _data_seek($n = 0) |
| 137 | { |
admin | 1716cb8 | 2006-10-25 05:12:34 +0000 | [diff] [blame] | 138 | return mssql_data_seek($this->result_id, $n); |
admin | d2dd031 | 2006-10-05 04:34:38 +0000 | [diff] [blame] | 139 | } |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 140 | |
| 141 | // -------------------------------------------------------------------- |
| 142 | |
| 143 | /** |
| 144 | * Result - associative array |
| 145 | * |
| 146 | * Returns the result set as an array |
| 147 | * |
| 148 | * @access private |
| 149 | * @return array |
| 150 | */ |
| 151 | function _fetch_assoc() |
| 152 | { |
| 153 | return mssql_fetch_assoc($this->result_id); |
| 154 | } |
| 155 | |
| 156 | // -------------------------------------------------------------------- |
| 157 | |
| 158 | /** |
| 159 | * Result - object |
| 160 | * |
| 161 | * Returns the result set as an object |
| 162 | * |
| 163 | * @access private |
| 164 | * @return object |
| 165 | */ |
| 166 | function _fetch_object() |
| 167 | { |
| 168 | return mssql_fetch_object($this->result_id); |
| 169 | } |
| 170 | |
| 171 | } |
| 172 | |
| 173 | ?> |