1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5
* An open source application development framework for PHP 5.1.6 or newer
9
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
10
* @license http://codeigniter.com/user_guide/license.html
11
* @link http://codeigniter.com
12
* @since Version 2.0.2
16
// --------------------------------------------------------------------
21
* This class extends the parent result class: CI_DB_result
24
* @author Esen Sagynov
25
* @link http://codeigniter.com/user_guide/database/
27
class CI_DB_cubrid_result extends CI_DB_result {
30
* Number of rows in the result set
37
return @cubrid_num_rows($this->result_id);
40
// --------------------------------------------------------------------
43
* Number of fields in the result set
50
return @cubrid_num_fields($this->result_id);
53
// --------------------------------------------------------------------
58
* Generates an array of column names
63
function list_fields()
65
return cubrid_column_names($this->result_id);
68
// --------------------------------------------------------------------
73
* Generates an array of objects containing field meta-data
82
$tablePrimaryKeys = array();
84
while ($field = cubrid_fetch_field($this->result_id))
87
$F->name = $field->name;
88
$F->type = $field->type;
89
$F->default = $field->def;
90
$F->max_length = $field->max_length;
92
// At this moment primary_key property is not returned when
93
// cubrid_fetch_field is called. The following code will
94
// provide a patch for it. primary_key property will be added
95
// in the next release.
97
// TODO: later version of CUBRID will provide primary_key
99
// When PK is defined in CUBRID, an index is automatically
100
// created in the db_index system table in the form of
101
// pk_tblname_fieldname. So the following will count how many
102
// columns are there which satisfy this format.
103
// The query will search for exact single columns, thus
104
// compound PK is not supported.
105
$res = cubrid_query($this->conn_id,
106
"SELECT COUNT(*) FROM db_index WHERE class_name = '" . $field->table .
107
"' AND is_primary_key = 'YES' AND index_name = 'pk_" .
108
$field->table . "_" . $field->name . "'"
113
$row = cubrid_fetch_array($res, CUBRID_NUM);
114
$F->primary_key = ($row[0] > 0 ? 1 : null);
118
$F->primary_key = null;
121
if (is_resource($res))
123
cubrid_close_request($res);
124
$this->result_id = FALSE;
133
// --------------------------------------------------------------------
140
function free_result()
142
if(is_resource($this->result_id) ||
143
get_resource_type($this->result_id) == "Unknown" &&
144
preg_match('/Resource id #/', strval($this->result_id)))
146
cubrid_close_request($this->result_id);
147
$this->result_id = FALSE;
151
// --------------------------------------------------------------------
156
* Moves the internal pointer to the desired offset. We call
157
* this internally before fetching results to make sure the
158
* result set starts at zero
163
function _data_seek($n = 0)
165
return cubrid_data_seek($this->result_id, $n);
168
// --------------------------------------------------------------------
171
* Result - associative array
173
* Returns the result set as an array
178
function _fetch_assoc()
180
return cubrid_fetch_assoc($this->result_id);
183
// --------------------------------------------------------------------
188
* Returns the result set as an object
193
function _fetch_object()
195
return cubrid_fetch_object($this->result_id);
201
/* End of file cubrid_result.php */
202
/* Location: ./system/database/drivers/cubrid/cubrid_result.php */
b'\\ No newline at end of file'