<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Postgres Result Class
* Postgres的结果类
*
* This class extends the parent result class: CI_DB_result
* 这个类继承父结果类:CI_DB_result
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_postgre_result extends CI_DB_result {
/**
* Number of rows in the result set
* 在结果集中的行数 pg_num_rows($this->result_id);
* @access public
* @return integer
*/
function num_rows()
{
return @pg_num_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
* 取得结果集中的字段值 pg_num_fields($this->result_id)
* @access public
* @return integer
*/
function num_fields()
{
return @pg_num_fields($this->result_id);
}
// --------------------------------------------------------------------
/**
* Fetch Field Names 取字段名..
* 循环结果集中字段的名称
* Generates an array of column names
* 生成数组的列名
* @access public
* @return array
*/
function list_fields()
{
$field_names = array();
//$this->num_fields() 取得当前的字段值的总数
for ($i = 0; $i < $this->num_fields(); $i++)
{
//pg_field_name($this->result_id, $i); 第一个参数是查询的结果,第二是字段的索引值
$field_names[] = pg_field_name($this->result_id, $i);
}
return $field_names;
}
// --------------------------------------------------------------------
/**
* Field data
* 现场数据
* Generates an array of objects containing field meta-data
* 生成数组包含元数据领域的对象
* @access public
* @return array
*/
function field_data()
{
$retval = array();
//取得每组数据的值
for ($i = 0; $i < $this->num_fields(); $i++)
{
$F = new stdClass();
//名称
$F->name = pg_field_name($this->result_id, $i);
//类型
$F->type = pg_field_type($this->result_id, $i);
//最大长度
$F->max_length = pg_field_size($this->result_id, $i);
//是否为主键
$F->primary_key = 0;
//默认值
$F->default = '';
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
* 释放查询结构
* @return null
*/
function free_result()
{
//如果is_resource($this->result_id)
if (is_resource($this->result_id))
{
pg_free_result($this->result_id); //释放 pg_free_result()
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Data Seek
* 搜索数据
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* 内部指针移动到所需的偏移。我们称之为此之前,内部取结果,以确保结果集从零开始
* @access private
* @return array
*/
function _data_seek($n = 0)
{
//将指针设置到查询资源的指定位置
return pg_result_seek($this->result_id, $n);
}
// --------------------------------------------------------------------
/**
* Result - associative array
* 结果 - 关联数组
* Returns the result set as an array
* 返回的结果集作为一个数组, pg_fetch_assoc(); mysql_fetch_assoc();
* @access private
* @return array
*/
function _fetch_assoc()
{
return pg_fetch_assoc($this->result_id);
}
// --------------------------------------------------------------------
/**
* Result - object
* 返回一个对象
* Returns the result set as an object
* pg_fetch_object($this->result_id);
* @access private
* @return object
*/
function _fetch_object()
{
return pg_fetch_object($this->result_id);
}
}
/* End of file postgre_result.php */
/* Location: ./system/database/drivers/postgre/postgre_result.php */