blob: c38658626c55be583bbab40990d69e35707db879 [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 {
114 if (is_resource($this->result_id))
115 {
116 pdo_free_result($this->result_id);
117 $this->result_id = FALSE;
118 }
119 }
120
121 // --------------------------------------------------------------------
122
123 /**
124 * Data Seek
125 *
126 * Moves the internal pointer to the desired offset. We call
127 * this internally before fetching results to make sure the
128 * result set starts at zero
129 *
130 * @access private
131 * @return array
132 */
133 function _data_seek($n = 0)
134 {
135 return FALSE;
136 }
137
138 // --------------------------------------------------------------------
139
140 /**
141 * Result - associative array
142 *
143 * Returns the result set as an array
144 *
145 * @access private
146 * @return array
147 */
148 function _fetch_assoc()
149 {
Timothy Warrenab347582011-08-23 12:29:29 -0400150 return $this->result_id->fetch(PDO::FETCH_ASSOC);
Timothy Warren80ab8162011-08-22 18:26:12 -0400151 }
152
153 // --------------------------------------------------------------------
154
155 /**
156 * Result - object
157 *
158 * Returns the result set as an object
159 *
160 * @access private
161 * @return object
162 */
163 function _fetch_object()
Timothy Warrenab347582011-08-23 12:29:29 -0400164 {
165 return $this->result_id->fetchObject();
Timothy Warren80ab8162011-08-22 18:26:12 -0400166 }
167
168}
169
170
171/* End of file pdo_result.php */
172/* Location: ./system/database/drivers/pdo/pdo_result.php */