blob: 5e136f581b5ab0226d6fc6506a61a930ea558dd6 [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 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
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 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * PDO Result Class
20 *
21 * This class extends the parent result class: CI_DB_result
22 *
23 * @category Database
24 * @author ExpressionEngine Dev Team
25 * @link http://codeigniter.com/user_guide/database/
26 */
27class CI_DB_pdo_result extends CI_DB_result {
28
29 /**
30 * Number of rows in the result set
31 *
32 * @access public
33 * @return integer
34 */
35 function num_rows()
36 {
Timothy Warrenab347582011-08-23 12:29:29 -040037 return $this->result_id->rowCount();
Timothy Warren80ab8162011-08-22 18:26:12 -040038 }
39
40 // --------------------------------------------------------------------
41
42 /**
43 * Number of fields in the result set
44 *
45 * @access public
46 * @return integer
47 */
48 function num_fields()
49 {
Timothy Warrenab347582011-08-23 12:29:29 -040050 return $this->result_id->columnCount();
Timothy Warren80ab8162011-08-22 18:26:12 -040051 }
52
53 // --------------------------------------------------------------------
54
55 /**
56 * Fetch Field Names
57 *
58 * Generates an array of column names
59 *
60 * @access public
61 * @return array
62 */
63 function list_fields()
64 {
Timothy Warrenab347582011-08-23 12:29:29 -040065 if ($this->db->db_debug)
Timothy Warren80ab8162011-08-22 18:26:12 -040066 {
Timothy Warrenab347582011-08-23 12:29:29 -040067 return $this->db->display_error('db_unsuported_feature');
Timothy Warren80ab8162011-08-22 18:26:12 -040068 }
Timothy Warrenab347582011-08-23 12:29:29 -040069 return FALSE;
Timothy Warren80ab8162011-08-22 18:26:12 -040070 }
71
72 // --------------------------------------------------------------------
73
74 /**
75 * Field data
76 *
77 * Generates an array of objects containing field meta-data
78 *
79 * @access public
80 * @return array
81 */
82 function field_data()
83 {
Timothy Warrenab347582011-08-23 12:29:29 -040084 $data = array();
85
86 try
Timothy Warren80ab8162011-08-22 18:26:12 -040087 {
Timothy Warrenab347582011-08-23 12:29:29 -040088 for($i = 0; $i < $this->num_fields(); $i++)
89 {
90 $data[] = $this->result_id->getColumnMeta($i);
91 }
92
93 return $data;
Timothy Warren80ab8162011-08-22 18:26:12 -040094 }
Timothy Warrenab347582011-08-23 12:29:29 -040095 catch (Exception $e)
96 {
97 if ($this->db->db_debug)
98 {
99 return $this->db->display_error('db_unsuported_feature');
100 }
101 return FALSE;
102 }
Timothy Warren80ab8162011-08-22 18:26:12 -0400103 }
104
105 // --------------------------------------------------------------------
106
107 /**
108 * Free the result
109 *
110 * @return null
111 */
112 function free_result()
113 {
Timothy Warren6a450cf2011-08-23 12:46:11 -0400114 if (is_object($this->result_id))
Timothy Warren80ab8162011-08-22 18:26:12 -0400115 {
Timothy Warren80ab8162011-08-22 18:26:12 -0400116 $this->result_id = FALSE;
117 }
118 }
119
120 // --------------------------------------------------------------------
121
122 /**
123 * Data Seek
124 *
125 * Moves the internal pointer to the desired offset. We call
126 * this internally before fetching results to make sure the
127 * result set starts at zero
128 *
129 * @access private
130 * @return array
131 */
132 function _data_seek($n = 0)
133 {
134 return FALSE;
135 }
136
137 // --------------------------------------------------------------------
138
139 /**
140 * Result - associative array
141 *
142 * Returns the result set as an array
143 *
144 * @access private
145 * @return array
146 */
147 function _fetch_assoc()
148 {
Timothy Warrenab347582011-08-23 12:29:29 -0400149 return $this->result_id->fetch(PDO::FETCH_ASSOC);
Timothy Warren80ab8162011-08-22 18:26:12 -0400150 }
151
152 // --------------------------------------------------------------------
153
154 /**
155 * Result - object
156 *
157 * Returns the result set as an object
158 *
159 * @access private
160 * @return object
161 */
162 function _fetch_object()
Timothy Warrenab347582011-08-23 12:29:29 -0400163 {
164 return $this->result_id->fetchObject();
Timothy Warren80ab8162011-08-22 18:26:12 -0400165 }
166
167}
168
169
170/* End of file pdo_result.php */
171/* Location: ./system/database/drivers/pdo/pdo_result.php */