blob: 6af7f94f2aa9757c76229946b8042352edfd7c54 [file] [log] [blame]
admin7b613c72006-09-24 18:05:17 +00001<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * Code Igniter
4 *
5 * An open source application development framework for PHP 4.3.2 or newer
6 *
7 * @package CodeIgniter
8 * @author Rick Ellis
9 * @copyright Copyright (c) 2006, pMachine, Inc.
10 * @license http://www.codeignitor.com/user_guide/license.html
11 * @link http://www.codeigniter.com
12 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * Postgres Result Class
20 *
21 * This class extends the parent result class: CI_DB_result
22 *
23 * @category Database
24 * @author Rick Ellis
25 * @link http://www.codeigniter.com/user_guide/database/
26 */
27class CI_DB_postgre_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 {
37 return @pg_num_rows($this->result_id);
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 {
50 return @pg_num_fields($this->result_id);
51 }
52
53 // --------------------------------------------------------------------
54
55 /**
56 * Field data
57 *
58 * Generates an array of objects containing field meta-data
59 *
60 * @access public
61 * @return array
62 */
63 function field_data()
64 {
65 $retval = array();
66 for ($i = 0; $i < $this->num_fields(); $i++)
67 {
68 $F = new stdClass();
69 $F->name = pg_field_name($this->result_id, $i);
70 $F->type = pg_field_type($this->result_id, $i);
71 $F->max_length = pg_field_size($this->result_id, $i);
72 $F->primary_key = $i == 0;
73 $F->default = '';
74
75 $retval[] = $F;
76 }
77
78 return $retval;
79 }
80
81 // --------------------------------------------------------------------
82
83 /**
84 * Free the result
85 *
86 * @return null
87 */
88 function free_result()
89 {
90 if (is_resource($this->result_id))
91 {
92 pg_free_result($this->result_id);
93 $this->result_id = FALSE;
94 }
95 }
96
97 // --------------------------------------------------------------------
98
99 /**
100 * Result - associative array
101 *
102 * Returns the result set as an array
103 *
104 * @access private
105 * @return array
106 */
107 function _fetch_assoc()
108 {
109 return pg_fetch_assoc($this->result_id);
110 }
111
112 // --------------------------------------------------------------------
113
114 /**
115 * Result - object
116 *
117 * Returns the result set as an object
118 *
119 * @access private
120 * @return object
121 */
122 function _fetch_object()
123 {
124 return pg_fetch_object($this->result_id);
125 }
126
127}
128
129?>