blob: 9d827895d6f0bfd8486ccf9c52111f710f4492c9 [file] [log] [blame]
Timothy Warren76e04352012-02-14 11:55:17 -05001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * CodeIgniter
4 *
5 * An open source application development framework for PHP 5.1.6 or newer
6 *
7 * NOTICE OF LICENSE
8 *
9 * Licensed under the Open Software License version 3.0
10 *
11 * This source file is subject to the Open Software License (OSL 3.0) that is
12 * bundled with this package in the files license.txt / license.rst. It is
13 * also available through the world wide web at this URL:
14 * http://opensource.org/licenses/OSL-3.0
15 * If you did not receive a copy of the license and are unable to obtain it
16 * through the world wide web, please send an email to
17 * licensing@ellislab.com so we can send you a copy immediately.
18 *
19 * @package CodeIgniter
20 * @author EllisLab Dev Team
21 * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
22 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
23 * @link http://codeigniter.com
24 * @since Version 3.0
25 * @filesource
26 */
27
28// ------------------------------------------------------------------------
29
30/**
31 * Interbase/Firebird Result Class
32 *
33 * This class extends the parent result class: CI_DB_result
34 *
35 * @category Database
36 * @author EllisLab Dev Team
37 * @link http://codeigniter.com/user_guide/database/
38 */
39class CI_DB_interbase_result extends CI_DB_result {
40
41 /**
42 * Number of rows in the result set
43 *
44 * @access public
45 * @return integer
46 */
Timothy Warren4be822b2012-02-14 12:07:34 -050047 public function num_rows()
Timothy Warren76e04352012-02-14 11:55:17 -050048 {
49 //Will have to manually calculate :(
50 $count = 0;
51
52 while($r = @ibase_fetch_row($this->result_id))
53 {
54 $count++;
55 }
56
57 return $count;
58 }
59
60 // --------------------------------------------------------------------
61
62 /**
63 * Number of fields in the result set
64 *
65 * @access public
66 * @return integer
67 */
Timothy Warren4be822b2012-02-14 12:07:34 -050068 public function num_fields()
Timothy Warren76e04352012-02-14 11:55:17 -050069 {
70 return @ibase_num_fields($this->result_id);
71 }
72
73 // --------------------------------------------------------------------
74
75 /**
76 * Fetch Field Names
77 *
78 * Generates an array of column names
79 *
80 * @access public
81 * @return array
82 */
Timothy Warren4be822b2012-02-14 12:07:34 -050083 public function list_fields()
Timothy Warren76e04352012-02-14 11:55:17 -050084 {
85 $field_names = array();
86 for ($i = 0; $i < $this->num_fields(); $i++)
87 {
88 $info = ibase_field_info($this->result_id, $i);
89 $field_names[] = $info['name'];
90 }
91
92 return $field_names;
93 }
94
95 // --------------------------------------------------------------------
96
97 /**
98 * Field data
99 *
100 * Generates an array of objects containing field meta-data
101 *
102 * @access public
103 * @return array
104 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500105 public function field_data()
Timothy Warren76e04352012-02-14 11:55:17 -0500106 {
107
108 $retval = array();
109 for ($i = 0; $i < $this->num_fields(); $i++)
110 {
111 $info = ibase_field_info($this->result_id, $i);
112
113 $F = new stdClass();
114 $F->name = $info['name'];
115 $F->type = $info['type'];
116 $F->max_length = $info['length'];
117 $F->primary_key = 0;
118 $F->default = '';
119
120 $retval[] = $F;
121 }
122
123 return $retval;
124 }
125
126 // --------------------------------------------------------------------
127
128 /**
129 * Free the result
130 *
131 * @return null
132 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500133 public function free_result()
Timothy Warren76e04352012-02-14 11:55:17 -0500134 {
135 @ibase_free_result($this->result_id);
136 }
137
138 // --------------------------------------------------------------------
139
140 /**
141 * Data Seek
142 *
143 * Moves the internal pointer to the desired offset. We call
144 * this internally before fetching results to make sure the
145 * result set starts at zero
146 *
147 * @access private
148 * @return array
149 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500150 public function _data_seek($n = 0)
Timothy Warren76e04352012-02-14 11:55:17 -0500151 {
152 //Interbase driver doesn't implement a sutable function
153 return array();
154 }
155
156 // --------------------------------------------------------------------
157
158 /**
159 * Result - associative array
160 *
161 * Returns the result set as an array
162 *
163 * @access private
164 * @return array
165 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500166 public function _fetch_assoc()
Timothy Warren76e04352012-02-14 11:55:17 -0500167 {
168 return @ibase_fetch_assoc($this->result_id);
169 }
170
171 // --------------------------------------------------------------------
172
173 /**
174 * Result - object
175 *
176 * Returns the result set as an object
177 *
178 * @access private
179 * @return object
180 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500181 public function _fetch_object()
Timothy Warren76e04352012-02-14 11:55:17 -0500182 {
183 return @ibase_fetch_object($this->result_id);
184 }
185
186}
187
188
189/* End of file interbase_result.php */
190/* Location: ./system/database/drivers/interbase/interbase_result.php */