/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. * MySQL Result Class
  18. *
  19. * This class extends the parent result class: CI_DB_result
  20. *
  21. * @category Database
  22. * @author ExpressionEngine Dev Team
  23. * @link http://codeigniter.com/user_guide/database/
  24. */
  25. class CI_DB_mysql_result extends CI_DB_result {
  26. /**
  27. * Number of rows in the result set
  28. *
  29. * @access public
  30. * @return integer
  31. */
  32. function num_rows()
  33. {
  34. return @mysql_num_rows($this->result_id);
  35. }
  36. // --------------------------------------------------------------------
  37. /**
  38. * Number of fields in the result set
  39. *
  40. * @access public
  41. * @return integer
  42. */
  43. function num_fields()
  44. {
  45. return @mysql_num_fields($this->result_id);
  46. }
  47. // --------------------------------------------------------------------
  48. /**
  49. * Fetch Field Names
  50. *
  51. * Generates an array of column names
  52. *
  53. * @access public
  54. * @return array
  55. */
  56. function list_fields()
  57. {
  58. $field_names = array();
  59. while ($field = mysql_fetch_field($this->result_id))
  60. {
  61. $field_names[] = $field->name;
  62. }
  63. return $field_names;
  64. }
  65. // --------------------------------------------------------------------
  66. /**
  67. * Field data
  68. *
  69. * Generates an array of objects containing field meta-data
  70. *
  71. * @access public
  72. * @return array
  73. */
  74. function field_data()
  75. {
  76. $retval = array();
  77. while ($field = mysql_fetch_field($this->result_id))
  78. {
  79. $F = new stdClass();
  80. $F->name = $field->name;
  81. $F->type = $field->type;
  82. $F->default = $field->def;
  83. $F->max_length = $field->max_length;
  84. $F->primary_key = $field->primary_key;
  85. $retval[] = $F;
  86. }
  87. return $retval;
  88. }
  89. // --------------------------------------------------------------------
  90. /**
  91. * Free the result
  92. *
  93. * @return null
  94. */
  95. function free_result()
  96. {
  97. if (is_resource($this->result_id))
  98. {
  99. mysql_free_result($this->result_id);
  100. $this->result_id = FALSE;
  101. }
  102. }
  103. // --------------------------------------------------------------------
  104. /**
  105. * Data Seek
  106. *
  107. * Moves the internal pointer to the desired offset. We call
  108. * this internally before fetching results to make sure the
  109. * result set starts at zero
  110. *
  111. * @access private
  112. * @return array
  113. */
  114. function _data_seek($n = 0)
  115. {
  116. return mysql_data_seek($this->result_id, $n);
  117. }
  118. // --------------------------------------------------------------------
  119. /**
  120. * Result - associative array
  121. *
  122. * Returns the result set as an array
  123. *
  124. * @access private
  125. * @return array
  126. */
  127. function _fetch_assoc()
  128. {
  129. return mysql_fetch_assoc($this->result_id);
  130. }
  131. // --------------------------------------------------------------------
  132. /**
  133. * Result - object
  134. *
  135. * Returns the result set as an object
  136. *
  137. * @access private
  138. * @return object
  139. */
  140. function _fetch_object()
  141. {
  142. return mysql_fetch_object($this->result_id);
  143. }
  144. }
  145. /* End of file mysql_result.php */
  146. /* Location: ./system/database/drivers/mysql/mysql_result.php */