~sianis/ddtp-lp-html/devel

« back to all changes in this revision

Viewing changes to frontend/ci.sys/database/drivers/odbc/odbc_result.php

  • Committer: István Nyitrai
  • Date: 2010-02-01 18:54:03 UTC
  • Revision ID: sianis@gmail.com-20100201185403-ize6gr594ij9rn97
Nightmonkey 2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
2
/**
 
3
 * CodeIgniter
 
4
 *
 
5
 * An open source application development framework for PHP 4.3.2 or newer
 
6
 *
 
7
 * @package             CodeIgniter
 
8
 * @author              ExpressionEngine Dev Team
 
9
 * @copyright   Copyright (c) 2008 - 2009, EllisLab, Inc.
 
10
 * @license             http://codeigniter.com/user_guide/license.html
 
11
 * @link                http://codeigniter.com
 
12
 * @since               Version 1.0
 
13
 * @filesource
 
14
 */
 
15
 
 
16
// ------------------------------------------------------------------------
 
17
 
 
18
/**
 
19
 * ODBC Result Class
 
20
 *
 
21
 * This class extends the parent result class: CI_DB_result
 
22
 *
 
23
 * @category    Database
 
24
 * @author              ExpressionEngine Dev Team
 
25
 * @link                http://codeigniter.com/user_guide/database/
 
26
 */
 
27
class CI_DB_odbc_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 @odbc_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 @odbc_num_fields($this->result_id);
 
51
        }
 
52
 
 
53
        // --------------------------------------------------------------------
 
54
 
 
55
        /**
 
56
         * Fetch Field Names
 
57
         *
 
58
         * Generates an array of column names
 
59
         *
 
60
         * @access      public
 
61
         * @return      array
 
62
         */
 
63
        function list_fields()
 
64
        {
 
65
                $field_names = array();
 
66
                for ($i = 0; $i < $this->num_fields(); $i++)
 
67
                {
 
68
                        $field_names[]  = odbc_field_name($this->result_id, $i);
 
69
                }
 
70
                
 
71
                return $field_names;
 
72
        }
 
73
 
 
74
        // --------------------------------------------------------------------
 
75
 
 
76
        /**
 
77
         * Field data
 
78
         *
 
79
         * Generates an array of objects containing field meta-data
 
80
         *
 
81
         * @access      public
 
82
         * @return      array
 
83
         */
 
84
        function field_data()
 
85
        {
 
86
                $retval = array();
 
87
                for ($i = 0; $i < $this->num_fields(); $i++)
 
88
                {
 
89
                        $F                              = new stdClass();
 
90
                        $F->name                = odbc_field_name($this->result_id, $i);
 
91
                        $F->type                = odbc_field_type($this->result_id, $i);
 
92
                        $F->max_length  = odbc_field_len($this->result_id, $i);
 
93
                        $F->primary_key = 0;
 
94
                        $F->default             = '';
 
95
 
 
96
                        $retval[] = $F;
 
97
                }
 
98
                
 
99
                return $retval;
 
100
        }
 
101
 
 
102
        // --------------------------------------------------------------------
 
103
 
 
104
        /**
 
105
         * Free the result
 
106
         *
 
107
         * @return      null
 
108
         */             
 
109
        function free_result()
 
110
        {
 
111
                if (is_resource($this->result_id))
 
112
                {
 
113
                        odbc_free_result($this->result_id);
 
114
                        $this->result_id = FALSE;
 
115
                }
 
116
        }
 
117
 
 
118
        // --------------------------------------------------------------------
 
119
 
 
120
        /**
 
121
         * Data Seek
 
122
         *
 
123
         * Moves the internal pointer to the desired offset.  We call
 
124
         * this internally before fetching results to make sure the
 
125
         * result set starts at zero
 
126
         *
 
127
         * @access      private
 
128
         * @return      array
 
129
         */
 
130
        function _data_seek($n = 0)
 
131
        {
 
132
                return FALSE;
 
133
        }
 
134
 
 
135
        // --------------------------------------------------------------------
 
136
 
 
137
        /**
 
138
         * Result - associative array
 
139
         *
 
140
         * Returns the result set as an array
 
141
         *
 
142
         * @access      private
 
143
         * @return      array
 
144
         */
 
145
        function _fetch_assoc()
 
146
        {
 
147
                if (function_exists('odbc_fetch_object'))
 
148
                {
 
149
                        return odbc_fetch_array($this->result_id);
 
150
                }
 
151
                else
 
152
                {
 
153
                        return $this->_odbc_fetch_array($this->result_id);
 
154
                }
 
155
        }
 
156
 
 
157
        // --------------------------------------------------------------------
 
158
 
 
159
        /**
 
160
         * Result - object
 
161
         *
 
162
         * Returns the result set as an object
 
163
         *
 
164
         * @access      private
 
165
         * @return      object
 
166
         */
 
167
        function _fetch_object()
 
168
        {
 
169
                if (function_exists('odbc_fetch_object'))
 
170
                {
 
171
                        return odbc_fetch_object($this->result_id);
 
172
                }
 
173
                else
 
174
                {
 
175
                        return $this->_odbc_fetch_object($this->result_id);
 
176
                }
 
177
        }
 
178
 
 
179
 
 
180
        /**
 
181
         * Result - object
 
182
         *
 
183
         * subsititutes the odbc_fetch_object function when
 
184
         * not available (odbc_fetch_object requires unixODBC)
 
185
         *
 
186
         * @access      private
 
187
         * @return      object
 
188
         */
 
189
        function _odbc_fetch_object(& $odbc_result) {
 
190
                $rs = array();
 
191
                $rs_obj = false;
 
192
                if (odbc_fetch_into($odbc_result, $rs)) {
 
193
                        foreach ($rs as $k=>$v) {
 
194
                                $field_name= odbc_field_name($odbc_result, $k+1);
 
195
                                $rs_obj->$field_name = $v;
 
196
                        }
 
197
                }
 
198
                return $rs_obj;
 
199
        }
 
200
 
 
201
 
 
202
        /**
 
203
         * Result - array
 
204
         *
 
205
         * subsititutes the odbc_fetch_array function when
 
206
         * not available (odbc_fetch_array requires unixODBC)
 
207
         *
 
208
         * @access      private
 
209
         * @return      array
 
210
         */
 
211
        function _odbc_fetch_array(& $odbc_result) {
 
212
                $rs = array();
 
213
                $rs_assoc = false;
 
214
                if (odbc_fetch_into($odbc_result, $rs)) {
 
215
                        $rs_assoc=array();
 
216
                        foreach ($rs as $k=>$v) {
 
217
                                $field_name= odbc_field_name($odbc_result, $k+1);
 
218
                                $rs_assoc[$field_name] = $v;
 
219
                        }
 
220
                }
 
221
                return $rs_assoc;
 
222
        }
 
223
 
 
224
}
 
225
 
 
226
 
 
227
/* End of file odbc_result.php */
 
228
/* Location: ./system/database/drivers/odbc/odbc_result.php */
 
 
b'\\ No newline at end of file'