mssql_result.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3. * CodeIgniter
  4. *
  5. * An open source application development framework for PHP 5.1.6 or newer
  6. *
  7. * @package CodeIgniter
  8. * @author ExpressionEngine Dev Team
  9. * @copyright Copyright (c) 2008 - 2011, 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. * MS SQL 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_mssql_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 @mssql_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 @mssql_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 = mssql_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 = mssql_fetch_field($this->result_id))
  78. {
  79. $F = new stdClass();
  80. $F->name = $field->name;
  81. $F->type = $field->type;
  82. $F->max_length = $field->max_length;
  83. $F->primary_key = 0;
  84. $F->default = '';
  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. mssql_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 mssql_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 mssql_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 mssql_fetch_object($this->result_id);
  143. }
  144. }
  145. /* End of file mssql_result.php */
  146. /* Location: ./system/database/drivers/mssql/mssql_result.php */