Timothy Warren | 817af19 | 2012-02-16 08:28:00 -0500 | [diff] [blame^] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
| 5 | * An open source application development framework for PHP 5.1.6 or newer |
| 6 | * |
| 7 | * NOTICE OF LICENSE |
Timothy Warren | 817af19 | 2012-02-16 08:28:00 -0500 | [diff] [blame^] | 8 | * |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 9 | * Licensed under the Open Software License version 3.0 |
Timothy Warren | 817af19 | 2012-02-16 08:28:00 -0500 | [diff] [blame^] | 10 | * |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 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 | */ |
| 39 | class CI_DB_interbase_result extends CI_DB_result { |
| 40 | |
Timothy Warren | 817af19 | 2012-02-16 08:28:00 -0500 | [diff] [blame^] | 41 | public $num_rows; |
| 42 | |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 43 | /** |
| 44 | * Number of rows in the result set |
| 45 | * |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 46 | * @return integer |
| 47 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 48 | public function num_rows() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 49 | { |
Timothy Warren | 817af19 | 2012-02-16 08:28:00 -0500 | [diff] [blame^] | 50 | if( ! is_null($this->num_rows)) |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 51 | { |
Timothy Warren | 817af19 | 2012-02-16 08:28:00 -0500 | [diff] [blame^] | 52 | return $this->num_rows; |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 53 | } |
| 54 | |
Timothy Warren | 817af19 | 2012-02-16 08:28:00 -0500 | [diff] [blame^] | 55 | return $this->num_rows = (isset($this->result_array()) ? count($this->result_array()) : 0; |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | // -------------------------------------------------------------------- |
| 59 | |
| 60 | /** |
| 61 | * Number of fields in the result set |
| 62 | * |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 63 | * @return integer |
| 64 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 65 | public function num_fields() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 66 | { |
| 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 Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 77 | * @return array |
| 78 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 79 | public function list_fields() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 80 | { |
| 81 | $field_names = array(); |
Timothy Warren | 817af19 | 2012-02-16 08:28:00 -0500 | [diff] [blame^] | 82 | for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++) |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 83 | { |
| 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 Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 98 | * @return array |
| 99 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 100 | public function field_data() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 101 | { |
| 102 | |
| 103 | $retval = array(); |
Timothy Warren | 817af19 | 2012-02-16 08:28:00 -0500 | [diff] [blame^] | 104 | for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++) |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 105 | { |
| 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 Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 128 | public function free_result() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 129 | { |
| 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 Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 142 | * @return array |
| 143 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 144 | public function _data_seek($n = 0) |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 145 | { |
Timothy Warren | 8be31a9 | 2012-02-15 11:48:57 -0500 | [diff] [blame] | 146 | //Interbase driver doesn't implement a suitable function |
Timothy Warren | 817af19 | 2012-02-16 08:28:00 -0500 | [diff] [blame^] | 147 | return FALSE; |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | // -------------------------------------------------------------------- |
| 151 | |
| 152 | /** |
| 153 | * Result - associative array |
| 154 | * |
| 155 | * Returns the result set as an array |
| 156 | * |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 157 | * @return array |
| 158 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 159 | public function _fetch_assoc() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 160 | { |
| 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 Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 171 | * @return object |
| 172 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 173 | public function _fetch_object() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 174 | { |
| 175 | return @ibase_fetch_object($this->result_id); |
| 176 | } |
| 177 | |
| 178 | } |
| 179 | |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 180 | /* End of file interbase_result.php */ |
| 181 | /* Location: ./system/database/drivers/interbase/interbase_result.php */ |