mssql_result.php 3.4 KB

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