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 | * |
Phil Sturgeon | 07c1ac8 | 2012-03-09 17:03:37 +0000 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.2.4 or newer |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 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 |
Andrey Andreev | 5ca0513 | 2012-07-05 12:06:34 +0300 | [diff] [blame] | 24 | * @since Version 1.0 |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 25 | * @filesource |
| 26 | */ |
| 27 | |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 28 | /** |
| 29 | * Interbase/Firebird Result Class |
| 30 | * |
| 31 | * This class extends the parent result class: CI_DB_result |
| 32 | * |
| 33 | * @category Database |
| 34 | * @author EllisLab Dev Team |
| 35 | * @link http://codeigniter.com/user_guide/database/ |
Andrey Andreev | 5ca0513 | 2012-07-05 12:06:34 +0300 | [diff] [blame] | 36 | * @since 3.0 |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 37 | */ |
Andrey Andreev | 2608687 | 2012-07-05 11:21:58 +0300 | [diff] [blame] | 38 | class CI_DB_ibase_result extends CI_DB_result { |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 39 | |
| 40 | /** |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 41 | * Number of fields in the result set |
| 42 | * |
Andrey Andreev | 60c9c99 | 2012-03-20 23:46:09 +0200 | [diff] [blame] | 43 | * @return int |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 44 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 45 | public function num_fields() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 46 | { |
| 47 | return @ibase_num_fields($this->result_id); |
| 48 | } |
| 49 | |
| 50 | // -------------------------------------------------------------------- |
| 51 | |
| 52 | /** |
| 53 | * Fetch Field Names |
| 54 | * |
| 55 | * Generates an array of column names |
| 56 | * |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 57 | * @return array |
| 58 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 59 | public function list_fields() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 60 | { |
| 61 | $field_names = array(); |
Timothy Warren | 2da66ed | 2012-02-20 17:54:39 -0500 | [diff] [blame] | 62 | for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++) |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 63 | { |
| 64 | $info = ibase_field_info($this->result_id, $i); |
| 65 | $field_names[] = $info['name']; |
| 66 | } |
| 67 | |
| 68 | return $field_names; |
| 69 | } |
| 70 | |
| 71 | // -------------------------------------------------------------------- |
| 72 | |
| 73 | /** |
| 74 | * Field data |
| 75 | * |
| 76 | * Generates an array of objects containing field meta-data |
| 77 | * |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 78 | * @return array |
| 79 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 80 | public function field_data() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 81 | { |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 82 | $retval = array(); |
Andrey Andreev | 60c9c99 | 2012-03-20 23:46:09 +0200 | [diff] [blame] | 83 | for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 84 | { |
| 85 | $info = ibase_field_info($this->result_id, $i); |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 86 | |
Andrey Andreev | 60c9c99 | 2012-03-20 23:46:09 +0200 | [diff] [blame] | 87 | $retval[$i] = new stdClass(); |
| 88 | $retval[$i]->name = $info['name']; |
| 89 | $retval[$i]->type = $info['type']; |
| 90 | $retval[$i]->max_length = $info['length']; |
| 91 | $retval[$i]->primary_key = 0; |
| 92 | $retval[$i]->default = ''; |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | return $retval; |
| 96 | } |
| 97 | |
| 98 | // -------------------------------------------------------------------- |
| 99 | |
| 100 | /** |
| 101 | * Free the result |
| 102 | * |
Andrey Andreev | 60c9c99 | 2012-03-20 23:46:09 +0200 | [diff] [blame] | 103 | * @return void |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 104 | */ |
Timothy Warren | 4be822b | 2012-02-14 12:07:34 -0500 | [diff] [blame] | 105 | public function free_result() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 106 | { |
| 107 | @ibase_free_result($this->result_id); |
| 108 | } |
| 109 | |
| 110 | // -------------------------------------------------------------------- |
| 111 | |
| 112 | /** |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 113 | * Result - associative array |
| 114 | * |
| 115 | * Returns the result set as an array |
| 116 | * |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 117 | * @return array |
| 118 | */ |
Timothy Warren | 9556214 | 2012-02-20 17:37:21 -0500 | [diff] [blame] | 119 | protected function _fetch_assoc() |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 120 | { |
Andrey Andreev | c7db6bb | 2012-07-05 15:11:20 +0300 | [diff] [blame] | 121 | return @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS); |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | // -------------------------------------------------------------------- |
| 125 | |
| 126 | /** |
| 127 | * Result - object |
| 128 | * |
| 129 | * Returns the result set as an object |
| 130 | * |
Andrey Andreev | 9a4f356 | 2012-07-06 11:57:37 +0300 | [diff] [blame^] | 131 | * @param string |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 132 | * @return object |
| 133 | */ |
Andrey Andreev | 9a4f356 | 2012-07-06 11:57:37 +0300 | [diff] [blame^] | 134 | protected function _fetch_object($class_name = 'stdClass') |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 135 | { |
Andrey Andreev | 9a4f356 | 2012-07-06 11:57:37 +0300 | [diff] [blame^] | 136 | $row = @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS); |
| 137 | |
| 138 | if ($class_name === 'stdClass' OR ! $row) |
| 139 | { |
| 140 | return $row; |
| 141 | } |
| 142 | |
| 143 | $class_name = new $class_name(); |
| 144 | foreach ($row as $key => $value) |
| 145 | { |
| 146 | $class_name->$key = $value; |
| 147 | } |
| 148 | |
| 149 | return $class_name; |
Timothy Warren | 3a4cdc6 | 2012-02-17 13:59:44 -0500 | [diff] [blame] | 150 | } |
Timothy Warren | 76e0435 | 2012-02-14 11:55:17 -0500 | [diff] [blame] | 151 | |
| 152 | } |
| 153 | |
Andrey Andreev | 2608687 | 2012-07-05 11:21:58 +0300 | [diff] [blame] | 154 | /* End of file ibase_result.php */ |
| 155 | /* Location: ./system/database/drivers/ibase/ibase_result.php */ |