在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
<?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 */ // -------------------------------------------------------------------- /** * MySQL Result Class * * MYSQL 返回类 * * 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_mysql_result extends CI_DB_result { /** * Number of rows in the result set * 在结果集中的行数 mysql_num_rows * @access public * @return integer */ function num_rows() { return @mysql_num_rows($this->result_id); } // -------------------------------------------------------------------- /** * Number of fields in the result set * 在结果集中的字段数 mysql_num_fields * @access public * @return integer */ function num_fields() { return @mysql_num_fields($this->result_id); } // -------------------------------------------------------------------- /** * Fetch Field Names * 循环取得字段名称 * * Generates an array of column names * 生成数组的列名 mysql_fetch_field() * @access public * @return array */ function list_fields() { $field_names = array(); while ($field = mysql_fetch_field($this->result_id)) { $field_names[] = $field->name; } return $field_names; } // -------------------------------------------------------------------- /** * Field data * 现场数据 * Generates an array of objects containing field meta-data * 生成一个对象数组,包含字段元数据 * @access public * @return array */ function field_data() { $retval = array(); while ($field = mysql_fetch_object($this->result_id)) { preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches); $type = (array_key_exists(1, $matches)) ? $matches[1] : NULL; $length = (array_key_exists(2, $matches)) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL; $F = new stdClass(); //空对馁 $F->name = $field->Field; //字段名称 $F->type = $type; //类型 $F->default = $field->Default;//默认值 $F->max_length = $length; //最大长度 $F->primary_key = ( $field->Key == 'PRI' ? 1 : 0 ); //是否为键 值 $retval[] = $F; } return $retval; } // -------------------------------------------------------------------- /** * Free the result * 释放结果 * * @return null */ function free_result() { if (is_resource($this->result_id)) { mysql_free_result($this->result_id); $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) { //mysql_data_seek() 函数移动内部结果的指针 return mysql_data_seek($this->result_id, $n); } // -------------------------------------------------------------------- /** * Result - associative array * 结果 - 关联数组 * Returns the result set as an array * 返回的结果集作为一个数组 * @access private * @return array */ function _fetch_assoc() { return mysql_fetch_assoc($this->result_id); } // -------------------------------------------------------------------- /** * Result - object * 返回一个对象 * * Returns the result set as an object * * @access private * @return object */ function _fetch_object() { return mysql_fetch_object($this->result_id); } } /* End of file mysql_result.php */ /* Location: ./system/database/drivers/mysql/mysql_result.php */
|
2022-08-15
2022-08-16
2022-08-16
2022-07-29
2022-08-18
请发表评论