blob: 559c2edb38e4979a1aec70048e3dba5db641a84e [file] [log] [blame]
Timothy Warren80ab8162011-08-22 18:26:12 -04001<?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 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * 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 *
Timothy Warren80ab8162011-08-22 18:26:12 -040019 * @package CodeIgniter
Derek Jonesf4a4bd82011-10-20 12:18:42 -050020 * @author EllisLab Dev Team
21 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
22 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Timothy Warren80ab8162011-08-22 18:26:12 -040023 * @link http://codeigniter.com
Timothy Warren018af7a2011-09-07 12:07:35 -040024 * @since Version 2.1.0
Timothy Warren80ab8162011-08-22 18:26:12 -040025 * @filesource
26 */
27
28// ------------------------------------------------------------------------
29
30/**
31 * PDO Result Class
32 *
33 * This class extends the parent result class: CI_DB_result
34 *
35 * @category Database
Derek Jonesf4a4bd82011-10-20 12:18:42 -050036 * @author EllisLab Dev Team
Timothy Warren80ab8162011-08-22 18:26:12 -040037 * @link http://codeigniter.com/user_guide/database/
38 */
39class CI_DB_pdo_result extends CI_DB_result {
40
41 /**
42 * Number of rows in the result set
43 *
44 * @access public
45 * @return integer
46 */
47 function num_rows()
48 {
Timothy Warrenab347582011-08-23 12:29:29 -040049 return $this->result_id->rowCount();
Timothy Warren80ab8162011-08-22 18:26:12 -040050 }
51
52 // --------------------------------------------------------------------
53
54 /**
55 * Number of fields in the result set
56 *
57 * @access public
58 * @return integer
59 */
60 function num_fields()
61 {
Timothy Warrenab347582011-08-23 12:29:29 -040062 return $this->result_id->columnCount();
Timothy Warren80ab8162011-08-22 18:26:12 -040063 }
64
65 // --------------------------------------------------------------------
66
67 /**
68 * Fetch Field Names
69 *
70 * Generates an array of column names
71 *
72 * @access public
73 * @return array
74 */
75 function list_fields()
76 {
Timothy Warrenab347582011-08-23 12:29:29 -040077 if ($this->db->db_debug)
Timothy Warren80ab8162011-08-22 18:26:12 -040078 {
Timothy Warrenab347582011-08-23 12:29:29 -040079 return $this->db->display_error('db_unsuported_feature');
Timothy Warren80ab8162011-08-22 18:26:12 -040080 }
Timothy Warrenab347582011-08-23 12:29:29 -040081 return FALSE;
Timothy Warren80ab8162011-08-22 18:26:12 -040082 }
83
84 // --------------------------------------------------------------------
85
86 /**
87 * Field data
88 *
89 * Generates an array of objects containing field meta-data
90 *
91 * @access public
92 * @return array
93 */
94 function field_data()
95 {
Timothy Warrenab347582011-08-23 12:29:29 -040096 $data = array();
97
98 try
Timothy Warren80ab8162011-08-22 18:26:12 -040099 {
Timothy Warrenab347582011-08-23 12:29:29 -0400100 for($i = 0; $i < $this->num_fields(); $i++)
101 {
102 $data[] = $this->result_id->getColumnMeta($i);
103 }
104
105 return $data;
Timothy Warren80ab8162011-08-22 18:26:12 -0400106 }
Timothy Warrenab347582011-08-23 12:29:29 -0400107 catch (Exception $e)
108 {
109 if ($this->db->db_debug)
110 {
111 return $this->db->display_error('db_unsuported_feature');
112 }
113 return FALSE;
114 }
Timothy Warren80ab8162011-08-22 18:26:12 -0400115 }
116
117 // --------------------------------------------------------------------
118
119 /**
120 * Free the result
121 *
122 * @return null
123 */
124 function free_result()
125 {
Timothy Warren6a450cf2011-08-23 12:46:11 -0400126 if (is_object($this->result_id))
Timothy Warren80ab8162011-08-22 18:26:12 -0400127 {
Timothy Warren80ab8162011-08-22 18:26:12 -0400128 $this->result_id = FALSE;
129 }
130 }
131
132 // --------------------------------------------------------------------
133
134 /**
135 * Data Seek
136 *
137 * Moves the internal pointer to the desired offset. We call
138 * this internally before fetching results to make sure the
139 * result set starts at zero
140 *
141 * @access private
142 * @return array
143 */
144 function _data_seek($n = 0)
145 {
146 return FALSE;
147 }
148
149 // --------------------------------------------------------------------
150
151 /**
152 * Result - associative array
153 *
154 * Returns the result set as an array
155 *
156 * @access private
157 * @return array
158 */
159 function _fetch_assoc()
160 {
Timothy Warrenab347582011-08-23 12:29:29 -0400161 return $this->result_id->fetch(PDO::FETCH_ASSOC);
Timothy Warren80ab8162011-08-22 18:26:12 -0400162 }
163
164 // --------------------------------------------------------------------
165
166 /**
167 * Result - object
168 *
169 * Returns the result set as an object
170 *
171 * @access private
172 * @return object
173 */
174 function _fetch_object()
Timothy Warrenab347582011-08-23 12:29:29 -0400175 {
176 return $this->result_id->fetchObject();
Timothy Warren80ab8162011-08-22 18:26:12 -0400177 }
178
179}
180
181
182/* End of file pdo_result.php */
183/* Location: ./system/database/drivers/pdo/pdo_result.php */