Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 1 | <?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 | */ |
| 27 | class 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 Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 37 | return $this->result_id->rowCount(); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 38 | } |
| 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 Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 50 | return $this->result_id->columnCount(); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 51 | } |
| 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 Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 65 | if ($this->db->db_debug) |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 66 | { |
Timothy Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 67 | return $this->db->display_error('db_unsuported_feature'); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 68 | } |
Timothy Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 69 | return FALSE; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 70 | } |
| 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 Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 84 | $data = array(); |
| 85 | |
| 86 | try |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 87 | { |
Timothy Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 88 | for($i = 0; $i < $this->num_fields(); $i++) |
| 89 | { |
| 90 | $data[] = $this->result_id->getColumnMeta($i); |
| 91 | } |
| 92 | |
| 93 | return $data; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 94 | } |
Timothy Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 95 | 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 Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | // -------------------------------------------------------------------- |
| 106 | |
| 107 | /** |
| 108 | * Free the result |
| 109 | * |
| 110 | * @return null |
| 111 | */ |
| 112 | function free_result() |
| 113 | { |
Timothy Warren | 6a450cf | 2011-08-23 12:46:11 -0400 | [diff] [blame^] | 114 | if (is_object($this->result_id)) |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 115 | { |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 116 | $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 Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 149 | return $this->result_id->fetch(PDO::FETCH_ASSOC); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 150 | } |
| 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 Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 163 | { |
| 164 | return $this->result_id->fetchObject(); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | } |
| 168 | |
| 169 | |
| 170 | /* End of file pdo_result.php */ |
| 171 | /* Location: ./system/database/drivers/pdo/pdo_result.php */ |