blob: 7d56c56c6071dfac5340b048b5fe7b8c7d482d3f [file] [log] [blame]
Timothy Warren817af192012-02-16 08:28:00 -05001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Timothy Warren76e04352012-02-14 11:55:17 -05002/**
3 * CodeIgniter
4 *
5 * An open source application development framework for PHP 5.1.6 or newer
6 *
7 * NOTICE OF LICENSE
Timothy Warren817af192012-02-16 08:28:00 -05008 *
Timothy Warren76e04352012-02-14 11:55:17 -05009 * Licensed under the Open Software License version 3.0
Timothy Warren817af192012-02-16 08:28:00 -050010 *
Timothy Warren76e04352012-02-14 11:55:17 -050011 * 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
Timothy Warren817af192012-02-16 08:28:00 -050041 public $num_rows;
42
Timothy Warren76e04352012-02-14 11:55:17 -050043 /**
44 * Number of rows in the result set
45 *
Timothy Warren76e04352012-02-14 11:55:17 -050046 * @return integer
47 */
Timothy Warren4be822b2012-02-14 12:07:34 -050048 public function num_rows()
Timothy Warren76e04352012-02-14 11:55:17 -050049 {
Timothy Warren817af192012-02-16 08:28:00 -050050 if( ! is_null($this->num_rows))
Timothy Warren76e04352012-02-14 11:55:17 -050051 {
Timothy Warren817af192012-02-16 08:28:00 -050052 return $this->num_rows;
Timothy Warren76e04352012-02-14 11:55:17 -050053 }
54
Timothy Warren817af192012-02-16 08:28:00 -050055 return $this->num_rows = (isset($this->result_array()) ? count($this->result_array()) : 0;
Timothy Warren76e04352012-02-14 11:55:17 -050056 }
57
58 // --------------------------------------------------------------------
59
60 /**
61 * Number of fields in the result set
62 *
Timothy Warren76e04352012-02-14 11:55:17 -050063 * @return integer
64 */
Timothy Warren4be822b2012-02-14 12:07:34 -050065 public function num_fields()
Timothy Warren76e04352012-02-14 11:55:17 -050066 {
67 return @ibase_num_fields($this->result_id);
68 }
69
70 // --------------------------------------------------------------------
71
72 /**
73 * Fetch Field Names
74 *
75 * Generates an array of column names
76 *
Timothy Warren76e04352012-02-14 11:55:17 -050077 * @return array
78 */
Timothy Warren4be822b2012-02-14 12:07:34 -050079 public function list_fields()
Timothy Warren76e04352012-02-14 11:55:17 -050080 {
81 $field_names = array();
Timothy Warren817af192012-02-16 08:28:00 -050082 for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++)
Timothy Warren76e04352012-02-14 11:55:17 -050083 {
84 $info = ibase_field_info($this->result_id, $i);
85 $field_names[] = $info['name'];
86 }
87
88 return $field_names;
89 }
90
91 // --------------------------------------------------------------------
92
93 /**
94 * Field data
95 *
96 * Generates an array of objects containing field meta-data
97 *
Timothy Warren76e04352012-02-14 11:55:17 -050098 * @return array
99 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500100 public function field_data()
Timothy Warren76e04352012-02-14 11:55:17 -0500101 {
102
103 $retval = array();
Timothy Warren817af192012-02-16 08:28:00 -0500104 for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++)
Timothy Warren76e04352012-02-14 11:55:17 -0500105 {
106 $info = ibase_field_info($this->result_id, $i);
107
108 $F = new stdClass();
109 $F->name = $info['name'];
110 $F->type = $info['type'];
111 $F->max_length = $info['length'];
112 $F->primary_key = 0;
113 $F->default = '';
114
115 $retval[] = $F;
116 }
117
118 return $retval;
119 }
120
121 // --------------------------------------------------------------------
122
123 /**
124 * Free the result
125 *
126 * @return null
127 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500128 public function free_result()
Timothy Warren76e04352012-02-14 11:55:17 -0500129 {
130 @ibase_free_result($this->result_id);
131 }
132
133 // --------------------------------------------------------------------
134
135 /**
136 * Data Seek
137 *
138 * Moves the internal pointer to the desired offset. We call
139 * this internally before fetching results to make sure the
140 * result set starts at zero
141 *
Timothy Warren76e04352012-02-14 11:55:17 -0500142 * @return array
143 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500144 public function _data_seek($n = 0)
Timothy Warren76e04352012-02-14 11:55:17 -0500145 {
Timothy Warren8be31a92012-02-15 11:48:57 -0500146 //Interbase driver doesn't implement a suitable function
Timothy Warren817af192012-02-16 08:28:00 -0500147 return FALSE;
Timothy Warren76e04352012-02-14 11:55:17 -0500148 }
149
150 // --------------------------------------------------------------------
151
152 /**
153 * Result - associative array
154 *
155 * Returns the result set as an array
156 *
Timothy Warren76e04352012-02-14 11:55:17 -0500157 * @return array
158 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500159 public function _fetch_assoc()
Timothy Warren76e04352012-02-14 11:55:17 -0500160 {
161 return @ibase_fetch_assoc($this->result_id);
162 }
163
164 // --------------------------------------------------------------------
165
166 /**
167 * Result - object
168 *
169 * Returns the result set as an object
170 *
Timothy Warren76e04352012-02-14 11:55:17 -0500171 * @return object
172 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500173 public function _fetch_object()
Timothy Warren76e04352012-02-14 11:55:17 -0500174 {
175 return @ibase_fetch_object($this->result_id);
176 }
177
178}
179
Timothy Warren76e04352012-02-14 11:55:17 -0500180/* End of file interbase_result.php */
181/* Location: ./system/database/drivers/interbase/interbase_result.php */