PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/halogy/database/drivers/mysql/mysql_result.php

https://bitbucket.org/haloweb/halogy-1.0/
PHP | 169 lines | 55 code | 23 blank | 91 comment | 4 complexity | 5fe7d1551ee9e38c37c369880fdcce9e MD5 | raw file
  1<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2/**
  3 * CodeIgniter
  4 *
  5 * An open source application development framework for PHP 4.3.2 or newer
  6 *
  7 * @package		CodeIgniter
  8 * @author		ExpressionEngine Dev Team
  9 * @copyright	Copyright (c) 2008 - 2009, 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 * MySQL 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_mysql_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 @mysql_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 @mysql_num_fields($this->result_id);
 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	{
 65		$field_names = array();
 66		while ($field = mysql_fetch_field($this->result_id))
 67		{
 68			$field_names[] = $field->name;
 69		}
 70		
 71		return $field_names;
 72	}
 73
 74	// --------------------------------------------------------------------
 75
 76	/**
 77	 * Field data
 78	 *
 79	 * Generates an array of objects containing field meta-data
 80	 *
 81	 * @access	public
 82	 * @return	array
 83	 */
 84	function field_data()
 85	{
 86		$retval = array();
 87		while ($field = mysql_fetch_field($this->result_id))
 88		{	
 89			$F				= new stdClass();
 90			$F->name 		= $field->name;
 91			$F->type 		= $field->type;
 92			$F->default		= $field->def;
 93			$F->max_length	= $field->max_length;
 94			$F->primary_key = $field->primary_key;
 95			
 96			$retval[] = $F;
 97		}
 98		
 99		return $retval;
100	}
101	
102	// --------------------------------------------------------------------
103
104	/**
105	 * Free the result
106	 *
107	 * @return	null
108	 */		
109	function free_result()
110	{
111		if (is_resource($this->result_id))
112		{
113			mysql_free_result($this->result_id);
114			$this->result_id = FALSE;
115		}
116	}
117
118	// --------------------------------------------------------------------
119
120	/**
121	 * Data Seek
122	 *
123	 * Moves the internal pointer to the desired offset.  We call
124	 * this internally before fetching results to make sure the
125	 * result set starts at zero
126	 *
127	 * @access	private
128	 * @return	array
129	 */
130	function _data_seek($n = 0)
131	{
132		return mysql_data_seek($this->result_id, $n);
133	}
134
135	// --------------------------------------------------------------------
136
137	/**
138	 * Result - associative array
139	 *
140	 * Returns the result set as an array
141	 *
142	 * @access	private
143	 * @return	array
144	 */
145	function _fetch_assoc()
146	{
147		return mysql_fetch_assoc($this->result_id);
148	}
149	
150	// --------------------------------------------------------------------
151
152	/**
153	 * Result - object
154	 *
155	 * Returns the result set as an object
156	 *
157	 * @access	private
158	 * @return	object
159	 */
160	function _fetch_object()
161	{
162		return mysql_fetch_object($this->result_id);
163	}
164	
165}
166
167
168/* End of file mysql_result.php */
169/* Location: ./system/database/drivers/mysql/mysql_result.php */